Is it possible to get DataRowIndex from RowDataBound event in GridView

Is it possible to get the DataRowIndex of a datarow binding from its parent DataTable. I would use it to point to the data again when I perform a delete operation. I cannot use DataItemIndex from GridView as rows with RowState = Deleted still exist. Therefore it will not point to the correct data line.

+2


a source to share


1 answer


In a RowDataBound, you can access the original row that is anchored and use it to determine the index of the row by accessing the data table of that row (I believe the DataRow class has a reference to the parent table).

You access this through e.Row.DataItem and convert it to the correct type. This is not possible unless you bind this index to the datakeynames collection or to a field inside the grid.



NTN.

0


a source







All Articles