Okay, generally, you have one dataset with both of the
tables in it. Then you need to set up a binding source,
and set the data member and data source
of your controls accordingly. Here's an example.
I don't know how you are creating your dataset. I am
going to assume you created it with the DataSetDesigner ?
Or are you creating it on your own? If you're creating
it on your own, that's a different ball of wax, because
you have to handle the relations on your own.
I have a dataset that has two tables: Customers and Orders.
(This runs against Northwind, so if you have that
installed, you can try this out.)
I set up a strongly-typed dataset using the Data Set
Designer with both of those tables in it, and there is
a field called CustomerID in the Orders table that links
to the CustomerID table in Customers. So Orders have a
Customer as a parent. The data relation between
the customer and the orders is defined as FK_Orders_Custo mers.
This is in Form_Load:
'First, populate the dataset.
Dim nwData As CustomersDataSe t = CustomersDataSe t.GetCustomers( )
'Set the data source for the binding source to the dataset.
CustomersBindin gSource.DataSou rce = nwData
'Add this so it knows which table to use .
CustomersBindin gSource.DataMem ber = "Customers"
'Set the data source for the grid to the customers binding source.
CustomersDataGr idView.DataSour ce = CustomersBindin gSource
'Add the binding for the child; set its binding source to the same
' one as the parent.
Customers_Order sBindingSource. DataSource = CustomersBindin gSource
'Set the datamember to the foreign key joining the two tables.
' You can see this on your CustomersDataSe t diagram.
Customers_Order sBindingSource. DataMember = "FK_Orders_Cust omers"
'Set the data source on the child grid to points at its binding source.
OrdersDataGridV iew.DataSource = Customers_Order sBindingSource
AddTextBoxDataB indings()
AddComboBoxData Bindings()
Here are the routines that bind the textboxes and combo box
in case you want them.
Private Sub AddTextBoxDataB indings()
'Bind each text box to the appropriate field in the
' CustomersBindin gSource
CustomerIDTextB ox.DataBindings .Add("Text", _
CustomersBindin gSource, "CustomerID ")
ContactNameText Box.DataBinding s.Add("Text", _
CustomersBindin gSource, "ContactNam e")
CompanyNameText Box.DataBinding s.Add("Text", _
CustomersBindin gSource, "CompanyNam e")
ContactPhoneTex tBox.DataBindin gs.Add("Text", _
CustomersBindin gSource, "Phone")
End Sub
Private Sub AddComboBoxData Bindings()
ContactsComboBo x.DataSource = CustomersBindin gSource
ContactsComboBo x.DisplayMember = "ContactNam e"
ContactsComboBo x.ValueMember = "CustomerID "
End Sub
Hope that provides enough info. This information
came out of Brian Noyes's book on Data Binding.
If you want to do updates, let them change the data in the
grid, then call the Update method on your table adapter:
CustomersTableA dapter.Update(d s)
I think that should work. Good luck.
Robin S.
-------------
"mike11d11" <mi*******@yaho o.comwrote in message
news:11******** **************@ f16g2000cwb.goo glegroups.com.. .
Yes data in the text boxes are bound to the WorkList table. My data
source is SQL 2000 server.