方法一:
var txtName = grid1.Rows[e.RowIndex].Cells[0].FindControl("txtName") as TextBox;
if (txtName != null)
{
// 读取值
//
}
方法二:
// 更新
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"];
// 执行相关的数据库更新操作
//