views:

54

answers:

1

Hi All,

Is it possible to retrieve the DataRowIndex of the binding datarow from its parent DataTable. I would use it to point again back to the datatable when i perform a delete operation. I can't use the DataItemIndex of GridView since the rows with RowState=Deleted still exists., so it won't point to the correct row of datatable.

A: 

Hey,

In RowDataBound, you can access the originating row that's bound, and use that to figure out the row index by accessing that row's data table (I believe the DataRow class has a reference to the parent table).

You access that through e.Row.DataItem, and convert it to the correct type. It is not possible unless you bind that index to the datakeynames collection, or to a field within the grid.

HTH.

Brian