We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

RowIndexToListManagerPosition() with heirarchical data

I have a heirarchical DataSet I have bound to a GridDataBoundGrid. When the user clicks on a cell I need to know which absolute row was clicked on in the DataSet. I am using RowIndexToListManagerPosition() per a previous posting, but it always returns 0 (zero). The docs seem to suggest that this function only works for the root DataTable and not for the children. If this is correct, is there a different way to do this? Tx, curt

4 Replies

AD Administrator Syncfusion Team April 2, 2003 04:10 PM UTC

Try this code to see if it gives you what you want:
GridCurrentCell cc = this.gridDataBoundGrid4.CurrentCell;

GridBoundRecordState rs = this.gridDataBoundGrid4.Binder.GetRecordStateAtRowIndex(cc.RowIndex);
DataRowView drv = (DataRowView) rs.ListManager.Current;
DataRow dr = drv.Row;
Console.WriteLine(dr[0].ToString() + "  " + dr[1].ToString() + "  " +  dr[2].ToString());


CK Curtis Koppang April 3, 2003 10:29 AM UTC

I don't need the DataRow, I need the index. This is because the DataSet is actually the View (Doc/View) and I use the index to corrolate the View (the DS) with the Doc. Thanks, curt


AD Administrator Syncfusion Team April 3, 2003 12:27 PM UTC

If you need the index of the row in the original datatable, then one way you can get it is to get the primary key value from the row, and then loop there the primary key column in the datatable looking for the key value from the row. Instead of looping to look for a key value, another option might be to create a hashtable that holds a correspondance between primary key value and the row index. SO, after loading your datatable, you could loop through all the rows adding an entry to the hashtable for each row. The Key in the hashtable entry would be the primary key value from the row, and the value member of the hashtable would be the row index from the table. Then instead of having to loop trough all rows in datatable to find the right primary key value, you could immediately pull it from the hashtable.


AD Administrator Syncfusion Team April 8, 2003 05:10 PM UTC

Using hashtable is really a brilliant idea!! I was exausted trying to find a way to get the row index beside using the loop method that you mentioned. I thin I will go the hashtable route. Thanks!! Ting > If you need the index of the row in the original datatable, then one way you can get it is to get the primary key value from the row, and then loop there the primary key column in the datatable looking for the key value from the row. > > Instead of looping to look for a key value, another option might be to create a hashtable that holds a correspondance between primary key value and the row index. SO, after loading your datatable, you could loop through all the rows adding an entry to the hashtable for each row. The Key in the hashtable entry would be the primary key value from the row, and the value member of the hashtable would be the row index from the table. Then instead of having to loop trough all rows in datatable to find the right primary key value, you could immediately pull it from the hashtable.

Loader.
Live Chat Icon For mobile
Up arrow icon