Getting the index of a row

M

Mark Rae

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);
}
 
G

Guest

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

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,690
Members
48,796
Latest member
Greg L.

Latest Threads

Top