lorena
Well-known member
I have a windows form that interfaces with a sql database. There is a combobox bound to the parent table and when the users selects a record from the combobox, the parent record will load into a series of textboxes and the child records (up to 4 of them) will load into a datagridview. I have a data access layer which loads adapters for the parent and child tables.
I have the parent record part figured out but the child rows are a problem.
Here is my code and any help would be appreciated:
I have the parent record part figured out but the child rows are a problem.
Here is my code and any help would be appreciated:
Code:
Private Sub rrNoComboBox_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles rrNoComboBox.SelectionChangeCommitted
Dim aBindingSource As BindingSource
Dim rrNoString As String
Dim index As Integer = 0
Dim recordDataRow As DataRow
Dim levelDataRow As DataRow ??
rrNoString = rrNoComboBox.SelectedValue.ToString
recordDataRow = aRiskReleaseDataSet.RiskReleaseRecord.FindByRiskRelNo(rrNoString)
This is where I tried to access the child rows and it loads the datagrid but only with the fieldnames for the parentrow
aBindingSource = New BindingSource
Try
With rrLevelDataGridView
.AutoGenerateColumns = True
aBindingSource.DataSource = recordDataRow.GetChildRows(rrNoString)
.DataSource = aBindingSource
.AllowUserToResizeRows = True
.BorderStyle = BorderStyle.Fixed3D
End With
Catch ex As Exception
MessageBox.Show("The Error is: " & ex.Message.ToString)
End Try
This code works to load the parent information
With Me
.progNoTextBox.Text = recordDataRow!ProgNo.ToString
End With
End Sub