Getting the index of a row

  • Thread starter Thread starter Guest
  • Start date Start date
Justin said:
How do I find the index number of a row inorder to update it?

If you're talking about the <asp:DataGrid> control, when you switch it into
Edit mode the row that you're currently editing is available through the
Item property of the DataGridCommandEventArgs parameter of the Edit method.
You can refer to each of the columns in that row by the Item property's
Cells collection. E.g. if you stored the dataset's primary key as a hidden
column in the datagrid, you could access it like this (for C#):

public void dgrd<DataGridName>_Edit(object sender, DataGridCommandEventArgs
e)
{
int intPrimaryKey = Convert.ToInt32(e.Item.Cells[0].Text);
}
 
Actually I am trying to find a row filled dataset table.

Thanks, Justin

Mark Rae said:
Justin said:
How do I find the index number of a row inorder to update it?

If you're talking about the <asp:DataGrid> control, when you switch it into
Edit mode the row that you're currently editing is available through the
Item property of the DataGridCommandEventArgs parameter of the Edit method.
You can refer to each of the columns in that row by the Item property's
Cells collection. E.g. if you stored the dataset's primary key as a hidden
column in the datagrid, you could access it like this (for C#):

public void dgrd<DataGridName>_Edit(object sender, DataGridCommandEventArgs
e)
{
int intPrimaryKey = Convert.ToInt32(e.Item.Cells[0].Text);
}
 
Back
Top