Dataset Relations in Code

C

Cdudej

Is the a way that is can do this but through 3 table

I have User - Statuslink - Status i need to link these together then i
want to add them to the treeview.

ds.Relations.Add("AuthorTitle",
ds.Tables["Authors"].Columns["au_id"],
ds.Tables["Titles"].Columns["au_id"]);

//Populate the TreeView from the DataSet.
foreach (DataRow rowAuthor in ds.Tables["Authors"].Rows)
{
nodeAuthor = new TreeNode();
nodeAuthor.Text = rowAuthor["au_lname"] + ", "
+ rowAuthor["au_fname"];
TreeView1.Nodes.Add(nodeAuthor);
foreach (DataRow rowTitle in

rowAuthor.GetChildRows("AuthorTitle"))
{
nodeTitle = new TreeNode();
nodeTitle.Text = rowTitle["Title"].ToString();
nodeAuthor.Nodes.Add(nodeTitle);
}
 
A

Andy O'Neill

Cdudej said:
Is the a way that is can do this but through 3 table

I have User - Statuslink - Status i need to link these together then i
want to add them to the treeview.

ds.Relations.Add("AuthorTitle",
ds.Tables["Authors"].Columns["au_id"],
ds.Tables["Titles"].Columns["au_id"]);

You add 3 tables, then 2 relations like you do there.
Then you do a foreach within a foreach within a foreach.
Which bit don't you get?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

multiple relation in dataset 1
treeview database 5

Top