Solved

sort DataSet with multiple column names

Posted on 2004-08-16
5
905 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
Comment Utility
Try this..

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

Expert Comment

by:vijay_a73
Comment Utility
hey..

its return ds and not diskDT.
0
 
LVL 18

Assisted Solution

by:DotNetLover_Baan
DotNetLover_Baan earned 250 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.   …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

8 Experts available now in Live!

Get 1:1 Help Now