Solved

sort DataSet with multiple column names

Posted on 2004-08-16
5
907 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
Visual Studio 2013 and Eclipse Neon 6 37
VB: Convert 2 dates to specific format 24 48
Footer for each row on Gridview 2 21
location of a form 2 13
IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

772 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