GridView中删除某行
--------------------编程问答-------------------- string sqlstr = "delete from [reg_stu] where [stu_id]=" + stu_id;stu_id里面有值没有? --------------------编程问答--------------------
protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)--------------------编程问答-------------------- 可以看看 GridView 72 绝技. --------------------编程问答-------------------- 跟跟断点,看看最终生成的语句
{
int stu_id = Convert.ToInt32(GridView2.DataKeys[e.RowIndex].Value.ToString());//你获取的行ID是GridView中的行索引,和数据库同步的?
string sqlstr = "delete from [reg_stu] where [stu_id]=" + stu_id;
SqlConnection con = new SqlConnection(sqlstr);
con.Open();
SqlCommand cmd = new SqlCommand(sqlstr,con);
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
GridView2.EditIndex =- 1;
this.bind();
}
补充:.NET技术 , ASP.NET