By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,478 Members | 1,833 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,478 IT Pros & Developers. It's quick & easy.

Is there method to sort my dataset table with one or mulitple colu

P: n/a
Are there any good built-in or availble functions that I can call to sort my
dataset datatalbe based on 1 or more of the table's columns?
--
Thanks.
Jan 31 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Pucca,

You can do it a couple of different ways. You'll find a lot of good
examples from a Google for DataTable.Select or DataView.Sort.

Most folks use System.Data.DataView.Sort since the results are a bit easier
to deal with than the array that DataTable.Select() returns.

see this article:
http://www.akadia.com/services/dotnet_filter_sort.html

Jason Vermilllion

"Pucca" wrote:
Are there any good built-in or availble functions that I can call to sort my
dataset datatalbe based on 1 or more of the table's columns?
--
Thanks.
Feb 1 '07 #2

P: n/a
I want to pass a sorted dataset table to Crystal Report becuase I think it
might give better performance. I don't think that dataview can be passed as
a datasource to crystal and the sorted result isn't saved to the dataset
table either, right?
--
Thanks.
"Jason Vermillion" wrote:
Pucca,

You can do it a couple of different ways. You'll find a lot of good
examples from a Google for DataTable.Select or DataView.Sort.

Most folks use System.Data.DataView.Sort since the results are a bit easier
to deal with than the array that DataTable.Select() returns.

see this article:
http://www.akadia.com/services/dotnet_filter_sort.html

Jason Vermilllion

"Pucca" wrote:
Are there any good built-in or availble functions that I can call to sort my
dataset datatalbe based on 1 or more of the table's columns?
--
Thanks.
Feb 1 '07 #3

P: n/a

I think you can pass a DataView to setdatasource(). I've not tested it
myself but see this post:
http://forums.microsoft.com/MSDN/Sho...70964&SiteID=1

I know there used to be a bug with SetDataSource() and you had to sort the
data in a DataView then copy it back into a clone of the original DataTable.
I think this has long been fixed though. The workaround went something like
this:

System.Data.DataTable origTbl; // Your original table
DataView dv;
System.Data.DataTable sortedTbl;

dv = origTbl.DefaultView;
dv.Sort = "col1 asc, col2 asc";

// Copy the sorted view into a new table..
sortedTbl = dv.Table.Clone();
for (int i = 0; i < dv.Count; i++)
{
sortedTbl.ImportRow(dv[i].Row);
}

Hope this helps,
Jason Vermillion
"Pucca" wrote:
I want to pass a sorted dataset table to Crystal Report becuase I think it
might give better performance. I don't think that dataview can be passed as
a datasource to crystal and the sorted result isn't saved to the dataset
table either, right?
--
Thanks.
"Jason Vermillion" wrote:
Pucca,

You can do it a couple of different ways. You'll find a lot of good
examples from a Google for DataTable.Select or DataView.Sort.

Most folks use System.Data.DataView.Sort since the results are a bit easier
to deal with than the array that DataTable.Select() returns.

see this article:
http://www.akadia.com/services/dotnet_filter_sort.html

Jason Vermilllion

"Pucca" wrote:
Are there any good built-in or availble functions that I can call to sort my
dataset datatalbe based on 1 or more of the table's columns?
--
Thanks.
Feb 1 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.