Getting the index of a row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I find the index number of a row inorder to update it?

Thanks, Justin.
 
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);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top