Solved

sort DataSet with multiple column names

Posted on 2004-08-16
5
906 Views
Last Modified: 2010-08-05
Hi I have one data table and I have usercontrol to return dataset of data table.
Because I have multiple columns in the data table , I like to sort by
"column1(String), column2(String), column3(DateTime) DESC" , and then return dataset.

Here is my code.
//create disk data table already, diskDT
//ds.Tables.Add(diskDT); //assign to dataset as a return later
string sortstr = "PatientID,ShotDate,ShotProc,FileName DESC";
DataView dv = new DataView();
dv = diskDT.DefaultView;
dv.Sort = sortstr;
ds = dv.Table.DataSet;
return ds

However, data set shows the original and did not sort it out.
How can I get the sort result to dataset?

 
0
Comment
Question by:young_nacs
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
vijay_a73 earned 250 total points
ID: 11813552
Try this..

string sortstr = "PatientID,ShotDate,ShotProc,FileName DESC";
diskDT.DefaultView.Sort = sortstr;
return diskDT;
0
 
LVL 2

Expert Comment

by:vijay_a73
ID: 11813596
hey..

its return ds and not diskDT.
0
 
LVL 18

Assisted Solution

by:DotNetLover_Baan
DotNetLover_Baan earned 250 total points
ID: 11816124
Hi there,
DataSet does NOT retain sorting. Not even a Table. We can sort only a VIEW. so, instead of returning DataSet/Table, return the sorted VIEW.

If you want the sorted records in the DataSet/Table, change your Sql query for sorted selection. Something like..
"SELECT * FROM Emp ORDER BY EmpID,EmpName, Dept DESC"  
-Baan
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB .NET application would like equitable cpu usage 3 25
Visual Studio editor? 1 38
Icons and Colors for Terms 3 24
SlingPlayer alternatives 1 35
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now