Hi Nicholas

Thanks

The problem is that the relation is at different levels

This is a dataset with 3 tables

table1 shows 2 relations l1 and l2

From Table1 I get a row collection from the parent row with relation

From 1 row from collection I get another collectiom with another relation

The Tables are all cascading

I am starting at the top level maybe I should start at the bottom???

I am submitting another question to the group because I am not sure if this

is easier or

xml and xpath if I use the xsd - this dataset can have any number of fields

and relations

and I get it down stream

Thanks

DataRow [] rows = ds.Tables[1].Rows[p].GetChildRows("l1");

for ( int t = 0; t < rows.Length; t++)

{

DataRow drc = rows[t]; //Current row

DataRow [] childrows = drc.GetChildRows("l2");

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in

message news:e0**************@TK2MSFTNGP09.phx.gbl...

Joe,

What I would do is before you loop through the rows in a table, cycle

through the relations to find out which one uses your table as the parent

table. Store those in a list.

Then, through each row, you can find the child rows by calling

GetChildRows on each row for the relation for each relation you know your

current table is a parent of.

Hope this helps.

--

- Nicholas Paldino [.NET/C# MVP]

- mv*@spam.guard.caspershouse.com

"Joe" <hc******@yahoo.com> wrote in message

news:e4**************@TK2MSFTNGP11.phx.gbl... Hi

I have a dataset with 3 tables and 2 relations

Is there a way to when I am at 1 row to tell if there is a relation on

that row ???

I have the code hardcoded but try to make it work if the # of tables and

#relations increase or decrease

So I can just pass any dataset and walk thru the rows??

Thanks

for (int p = 0; p < ds.Tables[1].Rows.Count; p++)

{

//Get Childs rows of parent

DataRow [] rows = ds.Tables[1].Rows[p].GetChildRows("Level1");

for ( int t = 0; t < rows.Length; t++)

{

DataRow drc = rows[t]; //Current row

//Get Childs rows of parent

DataRow [] childrows = drc.GetChildRows("Level2");

}

}