Hi,

I need to export the contents of a DataTable in a Dataset to a text file in
a particual row order. I guess I need to use the DefaultDavaView but I
think I am doing something wrong since traversing the rows in the table
doesn't show them in the correct order.

Thanks

Jeronimo Bertran

Re: Sorting a Dataset table by Miha

Miha
Sat Apr 01 02:47:19 CST 2006

DataView sorting affects just dataview.+ (it doesn't actually sort
DataTable).
You should iterate over DataView rows instead.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Jeronimo Bertran" <jeronimo.bertran@newsgroup.nospam> wrote in message
news:Xns9797E4841D812publicjbbertrancom@207.46.248.16...
> Hi,
>
> I need to export the contents of a DataTable in a Dataset to a text file
> in
> a particual row order. I guess I need to use the DefaultDavaView but I
> think I am doing something wrong since traversing the rows in the table
> doesn't show them in the correct order.
>
> Thanks
>
> Jeronimo Bertran



Re: Sorting a Dataset table by Cor

Cor
Sat Apr 01 06:02:21 CST 2006

Jeronimo,

You are right, but we cannot see what you do wrong if we don't see the code
that you use to go trough that defaultview.

Cor


"Jeronimo Bertran" <jeronimo.bertran@newsgroup.nospam> schreef in bericht
news:Xns9797E4841D812publicjbbertrancom@207.46.248.16...
> Hi,
>
> I need to export the contents of a DataTable in a Dataset to a text file
> in
> a particual row order. I guess I need to use the DefaultDavaView but I
> think I am doing something wrong since traversing the rows in the table
> doesn't show them in the correct order.
>
> Thanks
>
> Jeronimo Bertran



Re: Sorting a Dataset table by Terry

Terry
Sat Apr 01 06:50:13 CST 2006


MyDataTable.DefaultView.Sort="Firstname ASC"

Will sort the DefaultView in ascending order Using the Firstname column ( Or
whatever column you have in there ).

HTH


--
Terry Burns
http://TrainingOn.net
"Jeronimo Bertran" <jeronimo.bertran@newsgroup.nospam> wrote in message
news:Xns9797E4841D812publicjbbertrancom@207.46.248.16...
> Hi,
>
> I need to export the contents of a DataTable in a Dataset to a text file
> in
> a particual row order. I guess I need to use the DefaultDavaView but I
> think I am doing something wrong since traversing the rows in the table
> doesn't show them in the correct order.
>
> Thanks
>
> Jeronimo Bertran



Re: Sorting a Dataset table by Jeronimo

Jeronimo
Sat Apr 01 14:33:36 CST 2006

Thanks,

Re: Sorting a Dataset table by Jeronimo

Jeronimo
Sat Apr 01 15:05:54 CST 2006

Sorry, here is a detailed description of the problem.


My dataset hast tow tables which are used as master/detail. Assume table1
is Customers and table2 is Orders. I need to export all of the orders for
a given customers in a particular order.


Thr relationship is defined as

this.relationFK_Orders_Customers = new System.Data.DataRelation
("FK_Orders_Customers", new System.Data.DataColumn[] {
this.tableCustomers.CustomerIDColumn}, new
System.Data.DataColumn[] {
this.tableOrders.CustomerIDColumn}, false);



Now, in order to export the records for a given customer row I am doing the
following:

// need to sort the orders
foreach (dataset.OrdersRow order in customerRow.GetChildRows
("FK_Orders_Customers"))
{

// Export order
}


I don't see how I can use the dataView here.

Thanks

Jeronimo Bertran

Re: Sorting a Dataset table by Cor

Cor
Sun Apr 02 01:27:35 CST 2006

Jeronimo,

You can go through the defaultview and than get from every datarowview that
you get the drv.row.getchildrows collection.

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

I hope this helps,

Cor

"Jeronimo Bertran" <jeronimo.bertran@newsgroup.nospam> schreef in bericht
news:Xns9798853F24F7publicjbbertrancom@207.46.248.16...
> Sorry, here is a detailed description of the problem.
>
>
> My dataset hast tow tables which are used as master/detail. Assume table1
> is Customers and table2 is Orders. I need to export all of the orders for
> a given customers in a particular order.
>
>
> Thr relationship is defined as
>
> this.relationFK_Orders_Customers = new System.Data.DataRelation
> ("FK_Orders_Customers", new System.Data.DataColumn[] {
> this.tableCustomers.CustomerIDColumn}, new
> System.Data.DataColumn[] {
> this.tableOrders.CustomerIDColumn}, false);
>
>
>
> Now, in order to export the records for a given customer row I am doing
> the
> following:
>
> // need to sort the orders
> foreach (dataset.OrdersRow order in customerRow.GetChildRows
> ("FK_Orders_Customers"))
> {
>
> // Export order
> }
>
>
> I don't see how I can use the dataView here.
>
> Thanks
>
> Jeronimo Bertran



Re: Sorting a Dataset table by Miha

Miha
Sun Apr 02 06:57:59 CDT 2006

Hi Jeronimo,

Instead of using GetChildRows, use new DataView over child table with
relation conditions (manually filtering rows).

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Jeronimo Bertran" <jeronimo.bertran@newsgroup.nospam> wrote in message
news:Xns9798853F24F7publicjbbertrancom@207.46.248.16...
> Sorry, here is a detailed description of the problem.
>
>
> My dataset hast tow tables which are used as master/detail. Assume table1
> is Customers and table2 is Orders. I need to export all of the orders for
> a given customers in a particular order.
>
>
> Thr relationship is defined as
>
> this.relationFK_Orders_Customers = new System.Data.DataRelation
> ("FK_Orders_Customers", new System.Data.DataColumn[] {
> this.tableCustomers.CustomerIDColumn}, new
> System.Data.DataColumn[] {
> this.tableOrders.CustomerIDColumn}, false);
>
>
>
> Now, in order to export the records for a given customer row I am doing
> the
> following:
>
> // need to sort the orders
> foreach (dataset.OrdersRow order in customerRow.GetChildRows
> ("FK_Orders_Customers"))
> {
>
> // Export order
> }
>
>
> I don't see how I can use the dataView here.
>
> Thanks
>
> Jeronimo Bertran



Re: Sorting a Dataset table by Jeronimo

Jeronimo
Mon Apr 03 20:08:56 CDT 2006

Ok, that's what I did.

Thanks