http://hi.baidu.com/hixmuhot/blog/item/437d99f17e19dba6a40f52f1.html
希望对你有帮助
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();
}