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

Can I map Grid cell to row in DataSource?

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? Tx, curt

5 Replies

AD Administrator Syncfusion Team March 26, 2003 11:30 PM UTC

Have you tried this.gridDataBoundGrid1.Binder.RowIndexToListManagerPosition to see if that will give you the value you want?


AU Andy Ullman March 27, 2003 03:33 PM UTC

Hey Curt! 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. Andy > Have you tried > > this.gridDataBoundGrid1.Binder.RowIndexToListManagerPosition > > to see if that will give you the value you want?


AU Andy Ullman March 27, 2003 03:58 PM UTC

Now I see my mistake. You access it like this: ds.Tables["table"].DefaultView[Binder.RowIndexToListManagerPosition] Compiles but still not working for me. ANdy


SG Sean Greer March 27, 2003 04:10 PM UTC

Does this not work? int nRowIndex = grid.Binder.CurrentRowIndex; int nListIndex = grid.Binder.RowIndexToListManagerPosition(nRowIndex); DataRowView drv = ds.YourTable.DefaultView[nListIndex];


AU Andy Ullman March 28, 2003 04:57 PM UTC

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. Andy

Loader.
Live Chat Icon For mobile
Up arrow icon