Datagrid with columns from two tables

Wedgetail

New member
Joined
Oct 26, 2006
Messages
3
Programming Experience
3-5
To the forum,

I am new to VB.net and database programing in general and have a question regarding the datagrid and databinding.

I have three tables with the following columns:
tblContacts:
- idContact
- FirstName
- Surname

tblContactNumbers:
- idContactNumber
- idContact
- idNumberType
- ContactNumber

tblNumberType:
- idNumberType
- NumberType

I have then set up relations between my two tables where:
- tblContacts.idContact to tblContactNumbers.idContact [one-many]
- tblNumberType.idNumberType to tblContactNumbers.idContact [one-many]

I have bound tblContacts to Datagrid 1.
When I select a record [contact] in Datagrid 1 I want the:
- Number Type and,
- ContactNumber
to display in a second datagrid [Datagrid 2].

I can not work out how to get the values to bind to Datagrid 2, or how to set Datagrid 2 to lookup/display the Number Type.

ANy help is greatly appreciated.

Cheers
 
Set DataGrid2's datasource to be an instance of the DataRelation between the relevant tables. Ensure BOTH tables are filled with related data - one mistake I made early on was in assuming that the relation would download related child data when i filled the parent :)
 
Back
Top