Hi,
I have a strongly typed dataset with 2 tables: Orders and OrdersDetails,
that have a parent-child relationship by OrderId.
I want to be able to work sequentually on each row in Orders and in
OrderDetails in the following manner:
foreach (TableRow HeadRow in Orders.Rows)
{
...
foreach(TableRow DetRow in OrdersDetails.Rows)
{
.....
}
}
My question is how can I make sure the inner foreach works only on the Rows
that have the same OrderId (the OrderId from the outter foreach)

Thanks

Re: Generating a collection from a data set table by Cor

Cor
Tue Jun 06 14:52:22 CDT 2006

Vi,

Why are you not using the every time the childcollection by the getchildrows
and do in that your foreach.

http://msdn2.microsoft.com/en-us/library/system.data.datarow.getchildrows.aspx

It is made for this you know.

I hope this helps,

Cor

"Vi" <Vi@discussions.microsoft.com> schreef in bericht
news:D5DAADEB-CE23-4CD5-B045-F9E2657557ED@microsoft.com...
> Hi,
> I have a strongly typed dataset with 2 tables: Orders and OrdersDetails,
> that have a parent-child relationship by OrderId.
> I want to be able to work sequentually on each row in Orders and in
> OrderDetails in the following manner:
> foreach (TableRow HeadRow in Orders.Rows)
> {
> ...
> foreach(TableRow DetRow in OrdersDetails.Rows)
> {
> .....
> }
> }
> My question is how can I make sure the inner foreach works only on the
> Rows
> that have the same OrderId (the OrderId from the outter foreach)
>
> Thanks



Re: Generating a collection from a data set table by Cor

Cor
Tue Jun 06 15:06:45 CDT 2006

doh,

Completely unreadable.

> Why are you not using the every time the childcollection by the
> getchildrows and do in that your foreach.

Why are you not using in your outerloop every time the method getchildrows
to get the childrowcollection of an order and go through that using a
foreach.

>
> http://msdn2.microsoft.com/en-us/library/system.data.datarow.getchildrows.aspx
>
> It is made for this you know.
>
> I hope this helps,
>
> Cor
>
> "Vi" <Vi@discussions.microsoft.com> schreef in bericht
> news:D5DAADEB-CE23-4CD5-B045-F9E2657557ED@microsoft.com...
>> Hi,
>> I have a strongly typed dataset with 2 tables: Orders and OrdersDetails,
>> that have a parent-child relationship by OrderId.
>> I want to be able to work sequentually on each row in Orders and in
>> OrderDetails in the following manner:
>> foreach (TableRow HeadRow in Orders.Rows)
>> {
>> ...
>> foreach(TableRow DetRow in OrdersDetails.Rows)
>> {
>> .....
>> }
>> }
>> My question is how can I make sure the inner foreach works only on the
>> Rows
>> that have the same OrderId (the OrderId from the outter foreach)
>>
>> Thanks
>
>