G
Guest
I'm having difficulty with identifying the selected DataRow in my DataGrid.
Here is the situation:
I have a DataSet with several tables and relationships between the tables.
This situation concerns a parent child table pair. I created a DataView for
my parent table. The child table is related with a ParentToChild
relationship. I defined two DataGridTableStyles, one each for the parent and
child tables and added them to the DataGrid.TableStyles.
The user selects a Parent row from the DataGrid DataView and then I use the
DataGrid.NavigateTo(myHitTest.Row, "ParentToChild") method to show the
related Child table rows. They are displayed as defined by the associated
DataGridTableStyles. Everything works find to this point.
Now, however, the user selects a row from the DataGrid and I need to know
the child table row that has been selected. I’ve tried several approaches but
with no success. Here is my latest attempt:
int intRow = 0;
foreach( DataRowView drv in myDataView )
if( myDataGrid.IsSelected(intRow++) )
OpenEntry( (int)drv.Row["entry_id"] );
The problem I have is that myDataView still returns the Parent table rows
and myDataGrid still refers to the Parent table as well (i.e. the selected
row is the one selected in the Parent table not the Child table rows
currently displayed).
How do I get at the data behind the displayed view?
Here is the situation:
I have a DataSet with several tables and relationships between the tables.
This situation concerns a parent child table pair. I created a DataView for
my parent table. The child table is related with a ParentToChild
relationship. I defined two DataGridTableStyles, one each for the parent and
child tables and added them to the DataGrid.TableStyles.
The user selects a Parent row from the DataGrid DataView and then I use the
DataGrid.NavigateTo(myHitTest.Row, "ParentToChild") method to show the
related Child table rows. They are displayed as defined by the associated
DataGridTableStyles. Everything works find to this point.
Now, however, the user selects a row from the DataGrid and I need to know
the child table row that has been selected. I’ve tried several approaches but
with no success. Here is my latest attempt:
int intRow = 0;
foreach( DataRowView drv in myDataView )
if( myDataGrid.IsSelected(intRow++) )
OpenEntry( (int)drv.Row["entry_id"] );
The problem I have is that myDataView still returns the Parent table rows
and myDataGrid still refers to the Parent table as well (i.e. the selected
row is the one selected in the Parent table not the Child table rows
currently displayed).
How do I get at the data behind the displayed view?