473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Parent child binding question

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
Jun 6 '06 #1
2 1422
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.colu mn_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

Jun 7 '06 #2
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

"Aphazel" <ap*****@o2.pl> wrote in message
news:e6**********@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.colu mn_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


Jun 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Satish | last post by:
Hi, I am facing problem with, sending data frm mdi child to mdi parent. I have search Dropdown in MDI form, depend on selection, or enter string(its like IE URL functionality) and click...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
8
by: Richard L Rosenheim | last post by:
I have a dataset containing a parent table related to a child table. The child table contains an ID field (which is configured as autonumber in the datatable), the ID of the parent, plus some...
0
by: Innova | last post by:
Hi, We are working on a gridview inside the gridview (parent-child) scenario. The data of child grid will depend on the data of parent. Objectives: 1.Add new row in parent grid after each row...
4
by: Richard Lewis Haggard | last post by:
What is the mechanism by which a child window can notify its parent that it has been clicked on? -- Richard Lewis Haggard www.Haggard-And-Associates.com
0
by: ppearson3000 | last post by:
I have 2 forms.. a customer form and an addnew customer form. Basicially when you click on the addnew button, the addnew form opens. In the parent form, I add a new item using the bindingsource......
6
by: Sashi | last post by:
class parent{ Parent(){}; ~Parent(){}; } Child: public Parent{ Child(){}; ~Child(){};
8
by: Rick | last post by:
VS 2005 I' m setting up a parent/child datagridviews in a form. I am doing a lot of this by hand coding in order to get the feel of things. I want a change in the parent table to trigger a...
3
by: zacks | last post by:
Forgive me if this has been already asked an answered, I did do a search both here and in VS2005 Help, but I can't find the answer to my question. I am developing an MDI application that is a...
6
by: SQACSharp | last post by:
I'm using the EnumChildWindows API with an EnumChildWndProc callback to populate the treeview. The output will be something similar to spy+ + How can I specify the parent when adding a new node...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.