473,472 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataRelation Parent/Child in DataGridView

Hello,

my problem is to show a datarelation between two tables (parent/child) in a
datagridview. It doesn't works. There is always shown only 1 table in the
grid
(in relation of DataMember-settings).

My code is:

DataSet ds = new DataSet();
ds.Tables.Add(parantTable); // Tablename "Parent"
ds.Tables.Add(childTable); // Tablename "Child"

DataColumn dcParent = parentTable.Columns["GroupID"];
DataColumn dcChild = childTable.Columns["GroupID"];

ds.Relations.Add("Rel", dcParent, dcChild, true);

datagridview1.DataSource = ds;

// I already tried:
// datagridview1.DataSource = ds;
// datagridview1.DataMember = "Parent.Rel";
// or
// datagridview1.DataSource = parantTable;

The datagridview1 shows always 1 table only (parent or child), but never
both
with the relation. Whats my mistake?

Thanks
Jan

Apr 22 '06 #1
1 12555
http://www.daveandal.net/books/6744/...d-dataset.aspx

hope this helps, Jan

"Jan Lorenz" <Kn*******@gmx.de> wrote in message
news:uz**************@TK2MSFTNGP03.phx.gbl...
Hello,

my problem is to show a datarelation between two tables (parent/child) in
a
datagridview. It doesn't works. There is always shown only 1 table in the
grid
(in relation of DataMember-settings).

My code is:

DataSet ds = new DataSet();
ds.Tables.Add(parantTable); // Tablename "Parent"
ds.Tables.Add(childTable); // Tablename "Child"

DataColumn dcParent = parentTable.Columns["GroupID"];
DataColumn dcChild = childTable.Columns["GroupID"];

ds.Relations.Add("Rel", dcParent, dcChild, true);

datagridview1.DataSource = ds;

// I already tried:
// datagridview1.DataSource = ds;
// datagridview1.DataMember = "Parent.Rel";
// or
// datagridview1.DataSource = parantTable;

The datagridview1 shows always 1 table only (parent or child), but never
both
with the relation. Whats my mistake?

Thanks
Jan

Apr 24 '06 #2

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

Similar topics

4
by: Ben R. | last post by:
This is taken from MSDN Documentation: It is important to understand the difference between a true join and the function of a DataRelation object. In a true join, records are taken from parent...
0
by: Paul | last post by:
Hi, I think there's a bug in the ComoBox when binding to a DataRelation. The problem is that SelectedValueChanged event is not always being called. Here is some code to reproduce the problem....
1
by: Johann Blake | last post by:
I have a dataset that contains a parent table and a child table. A DataRelation exists between the two. I was under the impression from reading the VS docs that when I filled the parent table, the...
4
by: Kevin Davis via DotNetMonster.com | last post by:
Aloha, I have a question when using the Datarelation. I built a dataset and need to use the Datarelation to build parent-child relationships. I have events that may or may not use resources. ...
0
by: Coco | last post by:
Hi, who knows how to update the 'child' textboxes in a datarelated situation if the child records "doesn't yet exitsts/are still empty"? The problem can be explained with the Northwind database....
2
by: Rich | last post by:
Hello, Following an example at http://www.vb-tips.com/dbpages.aspx?IA=DG (by Cor Lightert and Ken Tucker) on binding a dataRelation to a Datagridview for sqlClient, I was able to view rows...
0
by: Susan Mackay | last post by:
I have an application that works well, with two DataGridViews connected with the necessary BindingSources, DataTables etc to have one DataGridView act as the parent and the other as the child in...
0
by: Bob | last post by:
On the edge of being off topic I guess but it is a C# problem. Dataset has three tables parent, child, grandson. Based on SQL Server 7 Database Parent joins child on an int column and is no...
1
by: Sep410 | last post by:
I have a child and parent condition on my datagrid. When the parent have child + will be shown beside the name of parent. The problem is when user click on the + sign another row will be shown which...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.