Looking for a way to get to the exact row in the DataTable, give the row index in the Grid. I am using the GridDataBoundGrid and am binding to a hierarchical DataSet.
Is there a way to do this?
ADAdministrator Syncfusion Team March 26, 2003 06:30 PM
Have you tried
to see if that will give you the value you want?
AUAndy UllmanMarch 27, 2003 10:33 AM
I'm working on the same issue. According to another post, Binder.RowIndexToListManagerPosition will work until the datagrid ordering changes (through a sort, on new rows added), then the index into Rows doesn't match up anymore. Instead, you should index through Table["table"].DefaultView.Item[Binder.RowIndexToListManagerPosition]
I can't test this though - for some reason, the compiler is complaining that Item is not a property of a DataView. The docs clearly state that it is (unless I'm missing something stupid). I'm going to install .net framwork sp2 and see if that fixes it.
> Have you tried
> to see if that will give you the value you want?
AUAndy UllmanMarch 27, 2003 10:58 AM
Now I see my mistake. You access it like this: ds.Tables["table"].DefaultView[Binder.RowIndexToListManagerPosition]
Compiles but still not working for me.
SGSean GreerMarch 27, 2003 11:10 AM
Does this not work?
int nRowIndex = grid.Binder.CurrentRowIndex;
int nListIndex = grid.Binder.RowIndexToListManagerPosition(nRowIndex);
DataRowView drv = ds.YourTable.DefaultView[nListIndex];
AUAndy UllmanMarch 28, 2003 11:57 AM
It was not giving me the correct row in the datatable when the datagrid was sorted. I studied a working example from another post and found one difference with my code - in my code, I set datagrid.datasource equal to the dataset, and datagrid.datamember = "table name". In the working example, datagrid.datasource is set to the datatable (the object). I made that change in my code and now it works. Looks like a bug. I'm using grid ver 1.5.2.