473,395 Members | 1,639 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,395 software developers and data experts.

Sorting dataset (C#)

Hello,
I'm trying to sort a dataset,
for some reason, when i use the writeXml of the dataset obeject I don't
see any change.

i'm trying to put the view into a dataview and then sort it but
nothings happens.

please advise.

May 2 '06 #1
4 25681
Hushpappy,

The DataView only sorts the data shown when you bind to it. As a
result, writing the data out to XML is not going to be affected, since that
is an operation on the DataSet, not the view.

What you will have to do is write the XML, and then transform it using
an XSLT transformation, writing the values in the order that you wish.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Hushpappy" <be******@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
Hello,
I'm trying to sort a dataset,
for some reason, when i use the writeXml of the dataset obeject I don't
see any change.

i'm trying to put the view into a dataview and then sort it but
nothings happens.

please advise.

May 2 '06 #2
Hushpappy,
Just for clarity's sake, you don't "Sort" a DataSet - you sort the
DataTable(s) that it contains. When you set a DataView (such as the
DefaultView of a datatable) and set its sort property, you are performing the
sort on the DataView, not on the DataTable from which it was derived.

If you actually want to reorder the rows in the DataTable itself, you would
need to reconstruct a new DataTable and import the rows in the correct order.

Hope that helps.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Hushpappy" wrote:
Hello,
I'm trying to sort a dataset,
for some reason, when i use the writeXml of the dataset obeject I don't
see any change.

i'm trying to put the view into a dataview and then sort it but
nothings happens.

please advise.

May 2 '06 #3
Hi,

You never physically reorder the datatable , what you do is create a view of
that data, this view can be sorted using any criteria you want.

In theory you do not need the datatable sorted, if all your iterations
operation happen using a view you will have the datatable sorted as needed.

This gives you the opportunity of having the same table with more than one
sorting at the same time.

In the weird case that you really want to save the values in a particular
order, there are several ways of doing it. you could create a new datatable
with the same schema and copy all the rows in the correct order.
Notice that there is nothing in the docs that assure you than even so you
will have the rows in the expected order though.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Hushpappy" <be******@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
Hello,
I'm trying to sort a dataset,
for some reason, when i use the writeXml of the dataset obeject I don't
see any change.

i'm trying to put the view into a dataview and then sort it but
nothings happens.

please advise.

May 2 '06 #4
Hushpappy wrote:
Hello,
I'm trying to sort a dataset,
for some reason, when i use the writeXml of the dataset obeject I don't
see any change.

i'm trying to put the view into a dataview and then sort it but
nothings happens.

please advise.


Hushpappy, if you are populating your dataset from the result of a SQL
query, why not use the "Order by" clause ?, just a thought ?
May 3 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.