Home All Groups Group Topic Archive Search About

Parent child binding question

Author
6 Jun 2006 4:11 PM
Bob
Got a datagridview with records bound to tableParent. Each time I go to a
new row (single select) in the datagrid view I want a series of textboxes as
well as another datagridview to shwo the realted records. The textboxes are
in tableChild1 and the other datagridview is of tableChild2, Both these
tables have a PK-FK relationship established in the dataset being used. How
can I do this?

Any help appreciated.

Bob

Author
7 Jun 2006 11:24 AM
Aphazel
Actually it's quite simple. One important thing is that all control bindings
must refer to tables and columns indirectly thru dataset. If you bind the
controls directly to particular tables/columns, you'll loose the synchro you
want while browsing tableParent.

You're supposed to name the tables (at least tableParent) and relations, if
they aren't named yet (use TableName and RelationName properties).

' let's say the DataSet object is ds
' for tableParent
parentGridView.DataSource = ds
parentGridView.DataMember = "tableParent_name"

' for tableChild1 each control must have separate binding, eg. binding to
sampleTextBox.Text looks like this:
sampeTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", ds,
"tableParent_name.parent_child2_relation_name.column_name", True))

' for tableChild2
child2GridView.DataSource = ds
child2GridView.DataMember = "tableParent_name.parent_child2_relation_name"

' FOLLOWING IS THE WRONG WAY
child2GridView.DataSource = ds.Tables("tableParent_name")
child2GridView.DataMember = "parent_child2_relation_name"

Hope you find it simple ;)
Aph

Show quoteHide quote
> Got a datagridview with records bound to tableParent. Each time I go to a
> new row (single select) in the datagrid view I want a series of textboxes
> as well as another datagridview to shwo the realted records. The textboxes
> are in tableChild1 and the other datagridview is of tableChild2, Both
> these tables have a PK-FK relationship established in the dataset being
> used. How can I do this?
>
> Any help appreciated.
>
> Bob
Author
7 Jun 2006 2:46 PM
Bob
Thanks Aph

Microsoft should hire you to do their documentation. Then idiots like me
could understand and cut through all the  marketing BS and unintelligible
jargon.
Bob

Show quoteHide quote
"Aphazel" <apha***@o2.pl> wrote in message
news:e66d6j$54u$1@nemesis.news.tpi.pl...
> Actually it's quite simple. One important thing is that all control
> bindings must refer to tables and columns indirectly thru dataset. If you
> bind the controls directly to particular tables/columns, you'll loose the
> synchro you want while browsing tableParent.
>
> You're supposed to name the tables (at least tableParent) and relations,
> if they aren't named yet (use TableName and RelationName properties).
>
> ' let's say the DataSet object is ds
> ' for tableParent
> parentGridView.DataSource = ds
> parentGridView.DataMember = "tableParent_name"
>
> ' for tableChild1 each control must have separate binding, eg. binding to
> sampleTextBox.Text looks like this:
> sampeTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", ds,
> "tableParent_name.parent_child2_relation_name.column_name", True))
>
> ' for tableChild2
> child2GridView.DataSource = ds
> child2GridView.DataMember = "tableParent_name.parent_child2_relation_name"
>
> ' FOLLOWING IS THE WRONG WAY
> child2GridView.DataSource = ds.Tables("tableParent_name")
> child2GridView.DataMember = "parent_child2_relation_name"
>
> Hope you find it simple ;)
> Aph
>
>> Got a datagridview with records bound to tableParent. Each time I go to a
>> new row (single select) in the datagrid view I want a series of textboxes
>> as well as another datagridview to shwo the realted records. The
>> textboxes are in tableChild1 and the other datagridview is of
>> tableChild2, Both these tables have a PK-FK relationship established in
>> the dataset being used. How can I do this?
>>
>> Any help appreciated.
>>
>> Bob
>
>