473,503 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Datagrid Parent/Child details databinding to SQL dataset

Hi, i have the following script which creates the two tables, i wish to have
a master/details form (with two datagrids on the same form, i have a many to
one relationship with tracks to album) but having i cant quite get it to
work. Please see the sql script below:

CREATE TABLE album(
id nvarchar(10) NOT NULL PRIMARY KEY,
title nvarchar(100),
artist nvarchar(100));

CREATE TABLE track(
album nvarchar(10),
dsk INTEGER,
posn INTEGER,
song nvarchar(255),
FOREIGN KEY (album) REFERENCES album(id));

All is well and i can add this as a new Datasource, i add both tables. In
the datasource explorer in VS2005 i click on album and it indeed shows the
track table as a sub table as shown below.

Album
|------ Id
|------ Title
|------ Artist
|------ Track (this is the table)

I then create a form and drag this dataset above but only the Album datagrid
is shown, how do i go about getting the Track sub-datagrid details on there
also? Can it be done automatically or do i need to add code?

Thanks in advance,

Chris

May 19 '07 #1
3 2043

Try creating a view (below is the code) in SQL server joining the table

IF OBJECT_ID('dbo.albumAndSongs')IS NOT NULL
DROP VIEW dbo.albumAndSongs
GO

CREATE VIEW dbo.albumAndSongs
AS
SELECT * FROM album a
INNER JOIN
track t ON a.id = t.album
GO

You should then be able to bind the view, like you did with the ablum table
to the gridview control through the datasource explorer in VS2005

"Chris" wrote:
Hi, i have the following script which creates the two tables, i wish to have
a master/details form (with two datagrids on the same form, i have a many to
one relationship with tracks to album) but having i cant quite get it to
work. Please see the sql script below:

CREATE TABLE album(
id nvarchar(10) NOT NULL PRIMARY KEY,
title nvarchar(100),
artist nvarchar(100));

CREATE TABLE track(
album nvarchar(10),
dsk INTEGER,
posn INTEGER,
song nvarchar(255),
FOREIGN KEY (album) REFERENCES album(id));

All is well and i can add this as a new Datasource, i add both tables. In
the datasource explorer in VS2005 i click on album and it indeed shows the
track table as a sub table as shown below.

Album
|------ Id
|------ Title
|------ Artist
|------ Track (this is the table)

I then create a form and drag this dataset above but only the Album datagrid
is shown, how do i go about getting the Track sub-datagrid details on there
also? Can it be done automatically or do i need to add code?

Thanks in advance,

Chris
May 21 '07 #2
On May 19, 4:34 pm, "Chris" <morl...@no.spam.gmail.remove.comwrote:
Hi, i have the following script which creates the two tables, i wish to have
a master/details form (with two datagrids on the same form, i have a many to
one relationship with tracks to album) but having i cant quite get it to
work. Please see the sql script below:

CREATE TABLE album(
id nvarchar(10) NOT NULL PRIMARY KEY,
title nvarchar(100),
artist nvarchar(100));

CREATE TABLE track(
album nvarchar(10),
dsk INTEGER,
posn INTEGER,
song nvarchar(255),
FOREIGN KEY (album) REFERENCES album(id));

All is well and i can add this as a new Datasource, i add both tables. In
the datasource explorer in VS2005 i click on album and it indeed shows the
track table as a sub table as shown below.

Album
|------ Id
|------ Title
|------ Artist
|------ Track (this is the table)

I then create a form and drag this dataset above but only the Album datagrid
is shown, how do i go about getting the Track sub-datagrid details on there
also? Can it be done automatically or do i need to add code?
It really should be as simple as first dragging the Album table (not
the dataset, itself) onto the form, and then dragging the Track table
to the form *from the Album table field list* (as you show it above)
in the datasource explorer.

May 21 '07 #3
It really should be as simple as first dragging the Album table (not
the dataset, itself) onto the form, and then dragging the Track table
to the form *from the Album table field list* (as you show it above)
in the datasource explorer
Thats strange, i did that just now and it works fine! I did do exactly
that before and it didnt work, still must be my fault somehow! Works a
treat thanks!

May 23 '07 #4

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

Similar topics

0
2091
by: Mark Tait | last post by:
Hi - I think I'm getting very tied up here. Using Web Matrix, and have posted in the asp.net forum, with no help unfortunately. I have a table, which has a parent/child relationship with itself....
3
3208
by: Darryn Ross | last post by:
Hi, How do i get my datagrid to display the contents of two related tables setup in my access database, so i can see the plus/minus sign to expand retract the Child details? Regards Darryn
1
2229
by: Jason Huang | last post by:
Hi, I want to create a Web form in asp.net, using C#. So in a web page, we have one DropDown List or one DataGrid, that when we click an item from a dropdown list, there will pop up another web...
3
5857
by: B-Dog | last post by:
I'm trying to comprehend the database features in VB and after tons of reading I'm not sure how do relationships. I want to display a parent column and the respective child columns on one line of...
1
1247
by: Brian | last post by:
Hello all, I was wondering how one does multiple headers and a with that multiple rows for one record in vb.net Example Headers: LastName FirstName Birthday DateHire Records: Doe Jane
0
2290
by: Iain | last post by:
Hi All My apologies for posting this here but the Delphi newsgroup is very slow. Using Borland Developer Studio 2006 - creating a C# .net application. I have a datagrid (id = "Documents")...
8
5959
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...
2
1208
by: truptidalia | last post by:
Hello, I have a Parent Form and a Child form. In Child form, I perform some search and store the data in Dataset. I want to pass that Dataset in the parent form. This is the way i have coded ...
0
2276
by: tschroeder250 | last post by:
Hello All, I am writing a form that allows maintenance of the fields of a table. Two of the controls on the form are comboboxes, where selecting a value in combobox A filters what appears in...
0
7083
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
7278
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
7328
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
5578
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
5011
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
4672
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
3166
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
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.