protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox chk = (CheckBox)GridView1.Rows[i].FindControl("chkCheck");
string Is_Audit = "通过审核";
string Class_Number = GridView1.Rows[i].Cells[0].ToString();
if (chk.Checked == true)
{
string sqlStr = "update Class set IS_Audit='"+Is_Audit+"'where Class_Number='" + Class_Number + "'";
SqlConnection myConn = GetCon();
myConn.Open();
SqlCommand myCmd = new SqlCommand(sqlStr, myConn);
myCmd.ExecuteNonQuery();
myCmd.Dispose();
myConn.Close();
GridViewBind();
}
}
}
{
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox chk = (CheckBox)GridView1.Rows[i].FindControl("chkCheck");
string Is_Audit = "通过审核";
string Class_Number = GridView1.Rows[i].Cells[0].ToString();
if (chk.Checked == true)
{
string sqlStr = "update Class set IS_Audit='"+Is_Audit+"'where Class_Number='" + Class_Number + "'";
SqlConnection myConn = GetCon();
myConn.Open();
SqlCommand myCmd = new SqlCommand(sqlStr, myConn);
myCmd.ExecuteNonQuery();
myCmd.Dispose();
myConn.Close();
GridViewBind();
}
}
}
这行可能有问题
上面Is_Audit+"'where 的Is_Audit和where之间的引号没有间隔,改过
Is_Audit+"' where
调试sqlStr是否正确