You need to create a dataAdapter for each table, then generate a DataSet for these. Add a DataRelation linking the two tables on the ID field.
If you are only showing midi names in the 1st datagrid, you need to format the datagrid at runtime, so a bit of coding is required. Basically you need to code to show that you only want the MidiName column and nothing else.
Bind the textboxes to the same data as that of the 1st datagrid. I'm assuming you don't want a textbox for MidiName as this is shown in the datagrid.
I have a similar setup, this is my code to format the datagrid to show only certain columns from my table:
Private Sub FormatRevisionsGrid()
With grdRevision
.DataSource = DsDWR1
'set the datagrid DataMember to the relationship between tables DWR and DWRSequence
.DataMember = "DWR.DWR_DWRSequence"
.ReadOnly = True
.CaptionText = "DWR Revisions: "
'turns off the datagrid relationship link (+) as WorkDone has a separate datagrid
.AllowNavigation = False
'set DataGrid Background Color
.BackgroundColor = System.Drawing.Color.White
' Set DataGrid Caption Background Color
.CaptionBackColor = System.Drawing.Color.Black
' Set DataGrid Caption Foreground Color
.CaptionForeColor = System.Drawing.Color.White
' Set DataGrid Parent Rows Background Color
.ParentRowsBackColor = System.Drawing.Color.Lavender
' Set DataGrid Parent Rows Foreground Color
.ParentRowsForeColor = System.Drawing.Color.SlateBlue
' Clear DataGrid Table Styles
.TableStyles.Clear()
End With
Dim tbl As New DataGridTableStyle
With tbl
'set the DataGrid table styles
.BackColor = System.Drawing.Color.White
.ForeColor = System.Drawing.Color.DarkSlateBlue
.GridLineColor = System.Drawing.Color.Black
.HeaderBackColor = System.Drawing.Color.WhiteSmoke
.HeaderForeColor = System.Drawing.Color.Black
.AlternatingBackColor = Color.LemonChiffon
.RowHeaderWidth = 10
'Map the DataGrid table to the DWRSequence table
.MappingName = "DWRSequence"
Dim col As DataGridTextBoxColumn
col = New DataGridTextBoxColumn
col.MappingName = "DWRSequence"
col.HeaderText = "Revision No"
col.Alignment = HorizontalAlignment.Center
col.Width = 100
.GridColumnStyles.Add(col)
col = New DataGridTextBoxColumn
col.MappingName = "Response"
col.HeaderText = "Response"
col.Alignment = HorizontalAlignment.Center
col.Width = 175
.GridColumnStyles.Add(col)
col = New DataGridTextBoxColumn
col.MappingName = "CustomerFeedback"
col.HeaderText = "Customer Feedback"
col.Alignment = HorizontalAlignment.Center
col.Width = 175
.GridColumnStyles.Add(col)
col = New DataGridTextBoxColumn
col.MappingName = "CreatedDate"
col.HeaderText = "Created Date"
col.Alignment = HorizontalAlignment.Center
col.Width = 110
.GridColumnStyles.Add(col)
grdRevision.TableStyles.Add(tbl)
End With
End Sub
You'll need to edit obviously to fit your requirements and setup.
You can also see about AllowNavigation - when you have a related datagrid it has a + next to all records in the datagrid to display related data. As you'll be having a seperate grid to show this related data, you need to set AllowNavigation = False.
Once your dataRelation is in place, and you bind datagrid1 to table1 and datagrid2 to table2, you will see that as you change row in datagrid1, datagrid2 corresponds with the related data for each record.
Hope that helps a bit more.
Regards,
Luke