在線等,,以下多選刪除報錯,
將 varchar 數值 'GridView1.DataKeys[gvr.DataItemIndex].Value' 轉換成資料型別為 int 的資料行語法錯誤。
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string connStr = ConfigurationManager.ConnectionStrings["BTS"].ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
DataSet ds = new DataSet();
SqlCommand comm = new SqlCommand();
SqlDataAdapter sqlad = new SqlDataAdapter();
comm.Connection = conn;
comm.CommandText = "select * from bts";
sqlad.SelectCommand = comm;
//Response.Write(sqlad.SelectCommand.CommandText);
sqlad.Fill(ds, "bts");
GridView1.DataSource = ds.Tables["bts"];
GridView1.DataBind();
}
}
protected void Button3_Click(object sender, EventArgs e)
{
foreach (GridViewRow gvr in GridView1.Rows)
{
CheckBox ch = (CheckBox)gvr.FindControl("ItemCheckBox");
if (ch.Checked)
{
//Ret2.Text += "<li>GridView1 您选择的是(键值):" + GridView1.DataKeys[gvr.DataItemIndex].Value.ToString();
string connStr = ConfigurationManager.ConnectionStrings["BTS"].ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
DataSet ds = new DataSet();
SqlCommand comm = new SqlCommand();
SqlDataAdapter sqlad = new SqlDataAdapter();
string sql;
sql = "delete from bts where au_id= 'GridView1.DataKeys[gvr.DataItemIndex].Value'";
comm.Connection = conn;
comm.CommandText = sql;
comm.ExecuteNonQuery();
}
}
}
protected void CheckAll(object sender, EventArgs e)
{
CheckBox cbx = (CheckBox)sender;
foreach (GridViewRow gvr in GridView1.Rows)
{
CheckBox ch = (CheckBox)gvr.FindControl("ItemCheckBox");
ch.Checked = cbx.Checked;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string connStr = ConfigurationManager.ConnectionStrings["BTS"].ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
DataSet ds = new DataSet();
SqlCommand comm = new SqlCommand();
SqlDataAdapter sqlad = new SqlDataAdapter();
comm.Connection = conn;
comm.CommandText = "select * from bts";
sqlad.SelectCommand = comm;
//Response.Write(sqlad.SelectCommand.CommandText);
sqlad.Fill(ds, "bts");
GridView1.DataSource = ds.Tables["bts"];
GridView1.DataBind();
}
}
protected void Button3_Click(object sender, EventArgs e)
{
foreach (GridViewRow gvr in GridView1.Rows)
{
CheckBox ch = (CheckBox)gvr.FindControl("ItemCheckBox");
if (ch.Checked)
{
//Ret2.Text += "<li>GridView1 您选择的是(键值):" + GridView1.DataKeys[gvr.DataItemIndex].Value.ToString();
string connStr = ConfigurationManager.ConnectionStrings["BTS"].ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
DataSet ds = new DataSet();
SqlCommand comm = new SqlCommand();
SqlDataAdapter sqlad = new SqlDataAdapter();
string sql;
sql = "delete from bts where au_id= 'GridView1.DataKeys[gvr.DataItemIndex].Value'";
comm.Connection = conn;
comm.CommandText = sql;
comm.ExecuteNonQuery();
}
}
}
protected void CheckAll(object sender, EventArgs e)
{
CheckBox cbx = (CheckBox)sender;
foreach (GridViewRow gvr in GridView1.Rows)
{
CheckBox ch = (CheckBox)gvr.FindControl("ItemCheckBox");
ch.Checked = cbx.Checked;
}
}
...全文
相关推荐
强力删除烦人的报错的OFFICE软件
强力删除烦人的报错的OFFICE软件"这个主题涉及到如何有效地解决这些错误并彻底卸载有问题的OFFICE软件。下面将详细讨论相关知识点。首先,我们需要了解OFFICE软件的基本结构。
laravel解决迁移文件一次删除创建字段报错的问题
这样,通过分开执行这两个迁移,可以确保每次操作都能被数据库接受,从而避免报错。
Yii使用DeleteAll连表删除出现报错问题的解决方法
在数据操作中,特别是涉及到多表关联删除时,我们可能会遇到一些问题。本文将详细探讨Yii框架中的DeleteAll方法在连表删除时可能出现的错误以及对应的解决方案。
android非常好的在线视频播放器源码(包含在线音频播放源码)_更改版
这是我前几天上传的资源,因为代码中一个bug报错导致不能缓存视频,当时没发现就上传上来了,后来发现又删除不了,只有重新在上传一次,为此我真诚的道歉!这是资源描述哈:最近项目需要,因此研究了下在线视频音
ZooKeeper报错调试
**KeeperErrorCode = Directory not empty for … 报错** 当尝试删除一个包含子节点的父节点时,会触发此错误。


