Last post May 05, 2006 04:23 AM by kayamben
Apr 30, 2006 09:08 AM|kayamben|LINK
I have a AJAX method that gets a dataset from a database and then return values to the user.
My problem is that I need to sort the dataset first and then display it to the user.
I understand that you have to bind the dataset into a control and then you will be able to see the sort
reasult, I don't have datagrid or any other control, how can I sort it?
Apr 30, 2006 09:39 AM|James Steele|LINK
You can create a DataView out of the DataSet and sort the DataView. Let say you have DataSet called ds and you want to sort by LastName ascending and DOB descending. Here is how you would do it:
Dim employeesV As DataView
employeesV = ds.Tables("Employees").DefaultView
employeesV.Sort = "LastName, DOB DESC"
Apr 30, 2006 10:03 AM|kayamben|LINK
ok, how can I use the sorted dataset later?
Apr 30, 2006 10:16 AM|James Steele|LINK
Apr 30, 2006 11:12 AM|kayamben|LINK
when I try to do this i'm getting the next error:
DataTable already belongs to another DataSet
Apr 30, 2006 12:28 PM|James Steele|LINK
May 01, 2006 01:07 AM|kayamben|LINK
should I see the xml sorted when I use the writeXml method, because I don't see any diff.
May 03, 2006 12:49 AM|James Steele|LINK
May 04, 2006 01:10 AM|kayamben|LINK
the code is very simple i'm getting a dataset and I want to sort it,
when I use the writeXml method I want to be able to see the difference before and after.
May 04, 2006 09:21 PM|rumbafum|LINK
using a view over a DataSet doesn't changes the initial item position in the DataSet, so when you do a writeXml you do't see any difference, if this is the case....
To see any changes you would need to create a new dataset and then add sorted rows
May 05, 2006 04:23 AM|kayamben|LINK
can you please provide me code sample?