如何获得GridView单元格的价值
问题描述:
我需要在单击编辑"按钮时获取gridview网格状单元格的值.
hi i need get the value of gridview praticular cell when edit button is clicked.
how to do ?
答
尝试以下操作
Try the below
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
//following will iterate all rows
foreach (GridViewRow row in GridView1.Rows)
{
string value = row.Cells[DesiredcolumnIndex].Text;
}
//following will give the value of single row that is being edited
int i = e.NewEditIndex;
string value = GridView1.Rows[i].Cells[DesiredcolumnIndex].Text;
}
与此相关的内容
GridView.Rows.Cells [i]
i = index
something linke this
GridView.Rows.Cells[i]
i=index