Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid displaying 2 tables

Status
Not open for further replies.

NickMalloy

Programmer
Apr 15, 2005
68
US
I have a windows form that has a datagrid on it. The datagrid is filled with a dataset that contains two tables with a relationship. Basically a parent child relationship. I call my datagrid datagrid1. When the datagrid loads the parent information I can select a little + next to the record that I want to show the children of that record. Once the children are showen I want to be able to select the child element and get the index of that child record. So if 3 records are shown on the datagrid and I select the second record the index would be 1. The problem is that I get the index number for what the parent record index was. How can I correct this? Here is my code for selecting the index. I know I can select the information from the child element, but I can't get the index number

Dim strEpisode As Integer
Dim iSelect As Integer
If (DataGrid1.DataMember.Length >= 25 AndAlso DataGrid1.DataMember.Substring(17, 8) = "Phase_II") Then
strMRN = DataGrid1(DataGrid1.CurrentRowIndex(), 0)
strEpisode = DataGrid1(DataGrid1.CurrentRowIndex(), 1)
strEpisode = DataGrid1(DataGrid1.CurrentRowIndex(), 1)
iSelect = 3
ElseIf (DataGrid1.DataMember.Length >= 16 AndAlso DataGrid1.DataMember.Substring(9, 7) = "Phase_I") Then
strMRN = DataGrid1(DataGrid1.CurrentRowIndex(), 0)
strEpisode = DataGrid1(DataGrid1.CurrentRowIndex(), 1)
iSelect = 2
Else
strMRN = DataGrid1(DataGrid1.CurrentRowIndex(), 0)
iSelect = 1
End If
 
Maybe you can include something like an ID field in the child recordset. Using this technique, you can retrieve the selected data using the ID-field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top