string sqlText = "(";
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cbx = (CheckBox)GridView1.Rows[i].FindControl("cbxId");
if (cbx.Checked == true)
{
sqlText = sqlText + GridView1.DataKeys[i].Value.ToString() + ",";
}
}
sqlText = sqlText.Substring(0, sqlText.Length - 1) + ")";
sqlText = "update tb_equipment set isactive = 0 where isactive=1 and number in" + sqlText;
z.ExecSql(sqlText);
这是我程序后台获取修改条件的代码
z.ExecSql(sqlText);是调用的公共类中的方法
#region 执行数据库添加,删除等逻辑操作,返回逻辑值
public Boolean ExecSql(string sQueryString)
{
con.Open();
SqlCommand dbCommand = new SqlCommand(sQueryString, con);
if (dbCommand.ExecuteNonQuery() > 0)
{
con.Close();
return true;
}
else
{
con.Close();
return false;
}
}
为什么运行出来老是出错

------解决思路----------------------
CheckBox cbx = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("cbxId");