你可以在 GridView 的 RowUpdating, RowDeleting 等事件中使用它。利用该方法,可以将值提取到所需的字典里去,然后再从字典中读取。这些字典包括:e.Keys, e.NewValues, e.OldValues 等。 一小段例子代码: // 更新 protected void grid1_RowUpdating(object sender, GridViewUpdateEventArgs e) { var row = grid1.Rows[e.RowIndex]; // 提取 Id 字段的值 grid1.Columns[0].ExtractValuesFromCell( e.Keys, row.Cells[0] as DataControlFieldCell, DataControlRowState.Edit, true /* include readonly */);
// 提取 Name 字段的值 grid1.Columns[1].ExtractValuesFromCell( e.NewValues, row.Cells[1] as DataControlFieldCell, DataControlRowState.Edit, true /* include readonly */);
var id = int.Parse(e.Keys["id"].ToString()); var name = (string) e.NewValues["name"];