473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Sorting Dataset

parshupooja
159 100+
Hey All,

I have DataSet. I want to sort it. Can anyone help.

I tried Smthing looking for Sort method but Don't see it.
Thanks
Mar 11 '08 #1
5 1327
nateraaaa
663 Expert 512MB
Hey All,

I have DataSet. I want to sort it. Can anyone help.

I tried Smthing looking for Sort method but Don't see it.
Thanks
You can't sort a dataset but you can sort using a dataview. Just create a new DataView with the dataset table and then used the Sort method to sort the dataview. See the link below on how to use the dataview.
http://www.knowdotnet.com/articles/dataviewsort.html

Nathan
Mar 11 '08 #2
kunal pawar
297 100+
u can not sort dataset but u can sort dataview using sort command of dataview
Mar 12 '08 #3
saran23
28
Hey All,

I have DataSet. I want to sort it. Can anyone help.

I tried Smthing looking for Sort method but Don't see it.
Thanks
Hi pooja,

I think this might help u...

put the dataset into a datatable and then to a dataview.
In dataview u hav the sort property.

Expand|Select|Wrap|Line Numbers
  1. Dataset ds
  2. Datatable dt=ds.Tables[0]
  3.  DataView dv = new DataView(dt);
  4.         dv.RowFilter = "ColumnName='" +Ur sort Value + "'";
  5.         return dv;
Thanks
Saran
Mar 12 '08 #4
parshupooja
159 100+
Hey,

Can I do something like this?

Dim dt As DataTable = MyDataSet.Tables(0)
Dim dv As DataView = New DataView(dt)
dv.RowFilter = ("start_dt")

I want to sort by date. I have coulmn start_dt. I tried this but it throws error.
I am using vb.net
Thanks,

Hi pooja,

I think this might help u...

put the dataset into a datatable and then to a dataview.
In dataview u hav the sort property.

Expand|Select|Wrap|Line Numbers
  1. Dataset ds
  2. Datatable dt=ds.Tables[0]
  3.  DataView dv = new DataView(dt);
  4.         dv.RowFilter = "ColumnName='" +Ur sort Value + "'";
  5.         return dv;
Thanks
Saran
Mar 14 '08 #5
balabaster
797 Expert 512MB
Hey,

Can I do something like this?

Dim dt As DataTable = MyDataSet.Tables(0)
Dim dv As DataView = New DataView(dt)
dv.RowFilter = ("start_dt")

I want to sort by date. I have coulmn start_dt. I tried this but it throws error.
I am using vb.net
Thanks,
That would be because RowFilter is exactly that - a filter consequently you would need to use dv.RowFilter = "start_dt = 'whatever is in start_dt'"

What you're looking for is dv.Sort

Expand|Select|Wrap|Line Numbers
  1. Dim dt As DataTable = MyDataSet.Tables(0)
  2. Dim dv As DataView = New DataView(dt)
  3. dv.Sort = "start_dt DESC"
You can substitute DESC for ASC if you wish to change the sort order, you can also use a comma to delimit - thus if you want to sort on multiple columns you can do that also:

dv.Sort = "<Column Name> [ASC|DESC]...[, Column n [ASC|DESC]"

Which basically translated =

dv.Sort = "Column1 ASC, Column2 DESC, Column3 DESC, Column4 ASC" etc etc.

Hope that helps
Mar 14 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dave S | last post by:
Hi, I'm using a datagrid to display contents of a dataset and I've set the datagrid to allow paging and sorting. Rather than re-retrieve from the DB, I store the original dataset in a Session...
11
by: Nikki | last post by:
Is it possible to sort a dataset rather than a dataview? I have a web service that returns a dataset which I would like to sort before returning it (this is so the sorting is standardised and so...
4
by: suzy | last post by:
hello. how can i sort data in a dataset? all the examples i have seen on msdn, etc are sorting a dataview. this works fine, but i want to return the results in xml and the dataview doesn't...
4
by: Mark Travis | last post by:
Hi all, I have written a simple Web Application that displays a query result onto a page using the ASP DataGrid. To Digress ======= Development information about the page is as follows 1....
3
by: Freeon | last post by:
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong...
4
by: Jon Paal | last post by:
I am passing an xml data file to a server control and need to sort the data. The data has three levels(tables). What is the recommended approach to do the sorting ? (using vb.net and asp.net...
4
by: samb | last post by:
When I use manual databinding to a GridView control, as bellow. 'Retrive a DataSet from database Dim ds As DataSet = uda.GetUsers(conectionString) 'gvUsers - The GridView gvUsers.DataSource...
4
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have a vb.net 2.0 app that is loading a GridView with a DataSource that is returned from a function. The definitions in the function are: Dim ReportDS As DataSet = New DataSet Dim...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
6
by: =?Utf-8?B?RGFu?= | last post by:
I am reposting a question from about 3 weeks ago ("sorting capability"). I have an aspx page in which I get the data from a database dynamically, through C# code, by creating a dynamic table...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.