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

DataRelation on Multible layers of DataRelations

I can relate two tables rather easily using the following code:
dsClub.Relations.Add("Section_Data",
dsClub.Tables["Section"].Columns["SectionID"],
dsClub.Tables["SData"].Columns["SectionID"]);

Which connects the "Section" table to the "SData" table rather easily using
the "SectionID" primary key. My question is:
I need to connect an "img_tbl" table to the "SData" table that is
constrained by the "Section" table so that the rows returned in the "SData"
table constrain the "img_tble"; ie, Parent/Child/Grandchild relationship.
The tables "SData" and "img_tbl" have their own Primary/Foreign key to
connect them together called "sdID" How do I set the the Grandchild
relationship between the two?
Nov 19 '05 #1
3 1504
Sam:

can't you just add a 2nd relationship:

dsClub.Relations.Add("Data_Image", dsClub.Tables["SData"].Columns["sdID"],
dsClub.Tables["img_tbl"].Columns["sdID"]);

then when you have a row in Section, you can call
GetChildRows("Section_Data")

which will return all the Child rows...and then you can take one of those
and call GetChildRows("Data_Image") to return the grandchildren rows

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"I am Sam" <Ia****@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
I can relate two tables rather easily using the following code:
dsClub.Relations.Add("Section_Data",
dsClub.Tables["Section"].Columns["SectionID"],
dsClub.Tables["SData"].Columns["SectionID"]);

Which connects the "Section" table to the "SData" table rather easily using the "SectionID" primary key. My question is:
I need to connect an "img_tbl" table to the "SData" table that is
constrained by the "Section" table so that the rows returned in the "SData" table constrain the "img_tble"; ie, Parent/Child/Grandchild relationship.
The tables "SData" and "img_tbl" have their own Primary/Foreign key to
connect them together called "sdID" How do I set the the Grandchild
relationship between the two?

Nov 19 '05 #2
Karl;

I did as you suggested but used a nested Repeater as follows:
<asp:Repeater ID="clubRep1" Runat="server">
<HeaderTemplate>
<table><tr><td>
</HeaderTemplate>
<ItemTemplate>
<asp:Repeater ID="clubRep2" DataSource='<%#
((DataRowView)Container.DataItem).Row.GetChildRows ("Section_Data")%>'
Runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# (DataBinder.Eval(Container.DataItem,
"[\"SectionDTitle\"]"))%></td>
</tr>
<tr>
<td>
<asp:Repeater DataSource='<%#
((DataRowView)Container.DataItem).Row.GetChildRows ("DataFK")%>'
Runat="server">
<ItemTemplate>
<img src='<%# "Sonar3/UploadImg/" +
DataBinder.Eval(Container.DataItem, "[\"ImgName\"]") +
DataBinder.Eval(Container.DataItem, "[\"imgType\"]")%>' />
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</ItemTemplate>
<FooterTemplate>
</td></tr></table>
</FooterTemplate>
</asp:Repeater>

I recieved an error as follows on the third repeater:

"Specified cast is not valid. "

Any Suggestions?

"Karl Seguin" wrote:
Sam:

can't you just add a 2nd relationship:

dsClub.Relations.Add("Data_Image", dsClub.Tables["SData"].Columns["sdID"],
dsClub.Tables["img_tbl"].Columns["sdID"]);

then when you have a row in Section, you can call
GetChildRows("Section_Data")

which will return all the Child rows...and then you can take one of those
and call GetChildRows("Data_Image") to return the grandchildren rows

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"I am Sam" <Ia****@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
I can relate two tables rather easily using the following code:
dsClub.Relations.Add("Section_Data",
dsClub.Tables["Section"].Columns["SectionID"],
dsClub.Tables["SData"].Columns["SectionID"]);

Which connects the "Section" table to the "SData" table rather easily

using
the "SectionID" primary key. My question is:
I need to connect an "img_tbl" table to the "SData" table that is
constrained by the "Section" table so that the rows returned in the

"SData"
table constrain the "img_tble"; ie, Parent/Child/Grandchild relationship.
The tables "SData" and "img_tbl" have their own Primary/Foreign key to
connect them together called "sdID" How do I set the the Grandchild
relationship between the two?


Nov 19 '05 #3
ooops...try using CreateChildView("XXXX") instead of GetChildRows this
will make your datasouce a DataView, making your individual records a
DataRowView GetChildRows makes your datasource an array of DataRows thus
making your invidual items DataRows (i think)...both would work though...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"I am Sam" <Ia****@discussions.microsoft.com> wrote in message
news:DC**********************************@microsof t.com...
Karl;

I did as you suggested but used a nested Repeater as follows:
<asp:Repeater ID="clubRep1" Runat="server">
<HeaderTemplate>
<table><tr><td>
</HeaderTemplate>
<ItemTemplate>
<asp:Repeater ID="clubRep2" DataSource='<%#
((DataRowView)Container.DataItem).Row.GetChildRows ("Section_Data")%>'
Runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# (DataBinder.Eval(Container.DataItem,
"[\"SectionDTitle\"]"))%></td>
</tr>
<tr>
<td>
<asp:Repeater DataSource='<%#
((DataRowView)Container.DataItem).Row.GetChildRows ("DataFK")%>'
Runat="server">
<ItemTemplate>
<img src='<%# "Sonar3/UploadImg/" +
DataBinder.Eval(Container.DataItem, "[\"ImgName\"]") +
DataBinder.Eval(Container.DataItem, "[\"imgType\"]")%>' />
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</ItemTemplate>
<FooterTemplate>
</td></tr></table>
</FooterTemplate>
</asp:Repeater>

I recieved an error as follows on the third repeater:

"Specified cast is not valid. "

Any Suggestions?

"Karl Seguin" wrote:
Sam:

can't you just add a 2nd relationship:

dsClub.Relations.Add("Data_Image", dsClub.Tables["SData"].Columns["sdID"], dsClub.Tables["img_tbl"].Columns["sdID"]);

then when you have a row in Section, you can call
GetChildRows("Section_Data")

which will return all the Child rows...and then you can take one of those and call GetChildRows("Data_Image") to return the grandchildren rows

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"I am Sam" <Ia****@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
I can relate two tables rather easily using the following code:
dsClub.Relations.Add("Section_Data",
dsClub.Tables["Section"].Columns["SectionID"],
dsClub.Tables["SData"].Columns["SectionID"]);

Which connects the "Section" table to the "SData" table rather easily

using
the "SectionID" primary key. My question is:
I need to connect an "img_tbl" table to the "SData" table that is
constrained by the "Section" table so that the rows returned in the

"SData"
table constrain the "img_tble"; ie, Parent/Child/Grandchild relationship. The tables "SData" and "img_tbl" have their own Primary/Foreign key to
connect them together called "sdID" How do I set the the Grandchild
relationship between the two?


Nov 19 '05 #4

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

Similar topics

1
by: Les | last post by:
I have a problem getting Dataset.WriteXml() to create a nested xml realtionship. All I get is an inline xsd (all nodes are children of the root). Documentation says to use...
4
by: niv | last post by:
Hi, I am unsure on how to retrieve data from tables 2 tables that are related through a relationship table.. TableOne -------- TableOneID TableOneDesc
3
by: Kevin | last post by:
Hi All this is going to be a lengthy questions do please bear with me.... I have a database that has three tables - Employees, ShiftHeader,ShiftDetails Now the employees table holds the...
0
by: Randy | last post by:
I have two DataTables in a DataSet. I create a DataRelation between two like-typed columns in the first and second tables, and it works exactly as expected. Unfortunately, the default behavior...
0
by: brian | last post by:
Situition: I am trying to fill a datagrid with data from 2 databases. I create 2 datasets and join them with a datarelation. Then I run the project and an error occurs 'This constraint cannot...
1
by: Thu | last post by:
Hi, I create a Dataset to link three tables in my Access database. E.g. The three tables are , , . I then create 2 DataRelations, 1st relation (Order_Cust_Rel) links and using CustomerID field...
7
by: Rich | last post by:
Hello, I am pulling master data from one master table and detail data from two detail tables. The rows from the master data are displayed in textboxes on my form which are bound to the data...
0
by: bterblanche | last post by:
I've got 3 tables. Table1 is the master table and tables 2 & 3 are detail tables related to table1. On the VB.net Windows form I've added several textboxes binded to table1 as a header and a...
5
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I need to create a data relation between two rows in two tables that were designed poorly years ago. TableA has the ID Number Column as a varchar(50) array, whereas TableB has the ID Number Column...
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...

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.