gridview 编辑更新代码更新不了值是怎么回事⼀

2025-03-23 06:48:30
推荐回答(2个)
回答1:

http://hi.baidu.com/hixmuhot/blog/item/437d99f17e19dba6a40f52f1.html
希望对你有帮助

回答2:

SqlConnection con = DBClass.Getcon();
try
{
con.Open();
string sql = "update Item set title='"+((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.Trim()+"'where Itemid='"+GridView1.DataKeys[e.RowIndex].Value.ToString()+"' ";
SqlCommand cmd = new SqlCommand(sql,con);
cmd.ExecuteNonQuery();
this.GridView1.EditIndex = -1;
bind();
}
catch (Exception ex)
{
this.Response.Write(ex.Message);

}
finally
{
con.Close();
}