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.
Unfortunately, activation email could not send to your email. Please try again.

RowIndexToListManagerPosition() with heirarchical data

Thread ID:

Created:

Updated:

Platform:

Replies:

3695 Apr 2,2003 08:29 AM Apr 8,2003 01:10 PM Windows Forms 4
loading
Tags: GridControl
Curtis Koppang
Asked On April 2, 2003 08:29 AM

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

Administrator [Syncfusion]
Replied On April 2, 2003 11:10 AM

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());

Curtis Koppang
Replied On April 3, 2003 05:29 AM

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

Administrator [Syncfusion]
Replied On April 3, 2003 07:27 AM

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.

Administrator [Syncfusion]
Replied On April 8, 2003 01:10 PM

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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;