Getting the content of a GridView cell on edit
Another common question I see on forums and lists is how to get the content of a GridView cell when in Edit mode. The following code demonstrates how to get the text of a cell at index position 3 using an OnEditing event.
VB.NET
Private Sub
GridView_RowEditing(
ByVal
sender
As Object
,
ByVal
e
As
GridViewEditEventArgs)
Dim
m_RowIndex
As Integer
m_RowIndex = e.NewEditIndex
Dim
m_ColumnText
As String
m_ColumnText = GridViewID.Rows(m_RowIndex).Cells(3).Text
End Sub
C#
private void
GridView_RowEditing(
object
sender,
GridViewEditEventArgs
e)
{
int
m_RowIndex;
m_RowIndex = e.NewEditIndex;
string
m_ColumnText;
m_ColumnText = GridViewID.Rows[m_RowIndex].Cells[3].Text;
}
R