473,387 Members | 1,440 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,387 software developers and data experts.

Master detail design

Hi

I am trying to create a master/detail form. I have my master and details
tables dragged onto the dataset. I have also dragged the fields from master
table on the form which has created the navigation toolbar for me and which
works fine with the master table. I also have a dataview on the same form
ready for detail table but as yet not assigned to the detail table. How can
I now create a master/detail relationship between my master and detail
tables such that the detail table shows up in the dataview control.?

Thanks

Regards
Jun 24 '07 #1
2 2256
John,

You would need to create a dataset relationship between your master and
details tables. For example, a Customers/Orders relationship is created as
follows:

DataRelation dr = new DataRelation("CustomerOrder",
ds.Tables["Customers"].Columns["CustID"],
ds.Tables["Orders"].Columns["CustID"]);
ds.Relations.Add(dr);

Next, for the customer/order example shown above, you would set up your
grids as follows:

productsGrid.DataSource = ds;
productsGrid.DataMember = ds["Customers"]

ordersGrid.DataSource = ds;
ordersGrid.DataMember = "Customers.CustomerOrder";

By the way, if you have a master row, and you want to programatically get
the children, do the following:

DataRow [] rowsOrder = rowCustomer.GetChildRows(ds.Relations["CustomerOrder"])

-Mike
"John" wrote:
Hi

I am trying to create a master/detail form. I have my master and details
tables dragged onto the dataset. I have also dragged the fields from master
table on the form which has created the navigation toolbar for me and which
works fine with the master table. I also have a dataview on the same form
ready for detail table but as yet not assigned to the detail table. How can
I now create a master/detail relationship between my master and detail
tables such that the detail table shows up in the dataview control.?

Thanks

Regards
Jun 24 '07 #2
John,

You would need to set up a relationship in your dataset for the mater/detail
tables. For example, a Customer/Order master detail would be done as follows:

DataRelation dr = new DataRelation("CustomerOrder",
ds.Tables["Customers"].Columns["CustID"],
ds.Tables["Orders"].Columns["CustID"]);
ds.Relations.Add(dr);

Then set up your grids as follows:

customersDataGridView.DataSource = ds;
customersDataGridView.DataMember = "Customers";

ordersDataGridView.DataSource = ds;
ordersDataGridView.DataMember = "Customers.FK_Orders_Customers"

If you want to programatically access summary row's detail records, do the
following:

DataRow[] detOrders =
rowCustomer.GetParentRows("Customers.FK_Orders_Cus tomers"]);

Hope this helps...
-Mike
"John" wrote:
Hi

I am trying to create a master/detail form. I have my master and details
tables dragged onto the dataset. I have also dragged the fields from master
table on the form which has created the navigation toolbar for me and which
works fine with the master table. I also have a dataview on the same form
ready for detail table but as yet not assigned to the detail table. How can
I now create a master/detail relationship between my master and detail
tables such that the detail table shows up in the dataview control.?

Thanks

Regards
Jun 24 '07 #3

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

Similar topics

2
by: Marcel | last post by:
Hi, I'm new to VS and ASP.NET and have a question about master/detail datagrids. I have a master datagrid filled with data via a component that contains a SQL adapter. Now I would like to fill...
2
by: ruca | last post by:
Hi, I have a master and a detail datagrid. I put detail grid showing insise of a column of master grid. The problem is that it's not what I really want. What I really want would be that the...
0
by: David Veeneman | last post by:
This post is for the Google crawler-- no response in required. Can a containment hierarchy made up of two collections derived from BindingList<T> be data-bound to master-detail dataGridView...
1
by: Sam | last post by:
Attached I am sending 2 URL's from MSFT ASP.net Quick Start Tutorial Web Site. 1) Run it URL: http://www.asp.net/QuickStart/aspnet/samples/data/GridViewMasterDetai... 2) View Source URL:...
0
by: Sam | last post by:
Sorry to post the same post multiple times but the URL Addresses were not Correct in Earlier Posts. Here are the correct URL's: 1) Run It URL is here: ...
1
by: Gary200 | last post by:
Hello All, I bind two datagrids in a master-detail relationship successfully. What I want is to set allowNew and allowDelete disabled in both datagrid using dataview. The code like this: ...
7
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent...
0
by: Mike Wilson | last post by:
Dear group, I have an invoice entry form, which is a simple Master fields / Detail grid. The main summary information of the invoice are stored in one table in a dataset, which is bound using a...
0
by: John | last post by:
Hi I am trying to create a master/detail form. I have my master and details tables dragged onto the dataset. I have also dragged the fields from master table on the form which has created the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.