Find the grid''s RowIndex of a DataRow from a nested DataTable

I have a set of 3 tables. One table is the root table and the others are subsequent child tables.
E.G.
Root Table
¦-Child Table
¦-GrandChild Table

How is it possible to retrieve the grid''s RowIndex of a given DataRow from a nested table? I have tried to use PositionToRowIndex and similar functions but they simply return the rowIndex of the root table and not the child table.

The reason for this is that I am remembering the state of a grid (ie what rows where expanded/collapsed including nested tables) so that after a refresh I can set the grid back to the state that it was in before the refresh.

Your help in this matter would be most appreciated.

2 Replies

AD Administrator Syncfusion Team September 26, 2006 09:25 AM UTC

Hi Tim,

You can get this from the GridBoundRecordState for the row. Here is some code snippet.

GridBoundRecordState rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex( gridRowIndex );
int pos = rs.Position;
CurrencyManager cm = rs.ListManager as CurrencyManager;
if(cm != null)
{
DataView dv = cm.List as DataView;
if(dv != null)
{
DataRow dr = dv[pos].Row;
Console.WriteLine(dr[0].ToString() + " " + dr[1].ToString());
}
}

Best Regards,
Haneef


TD Timothy Duly September 26, 2006 09:48 AM UTC

How did you get the GridRowIndex in the first place? It is the RowIndex that I am trying to find.

Basically, I have a DataRow from a nested table that I have selected programmatically and not through clicking on the grid. I now need to find out the grid''s RowIndex of this DataRow.

Loader.
Up arrow icon