473,395 Members | 1,457 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.

DataSet Sorting Problem - HELP!

I have a Dataset that I read from SQL Server.
The dataset can contain more items that I want to display. When I try to
resort the dataset it doesn't sort.

Here is the Syntax. I am not sure what the problem is:

DataSet oDS = (DataSet)Cache["SearchResults"];
Sort = Session["Sort"];

// Removes All Sorting Signs

int iTotalRows = Convert.ToInt32(oDS.Tables[0].Rows.Count);
if (iTotalRows>0)
{
Session.Add("CurrentPage", 1);
Session.Add("TotalPages",
Convert.ToInt32((oDS.Tables[0].Rows.Count - 1) / PageResults)+ 1) ;
Session.Add("TotalRows", iTotalRows);
}

oDS.Tables[0].DefaultView.Sort = Sort;
Cache["SearchResults"] = oDS;

DataSet oDSTemp = oDS.Clone();
DataTable dtTemp = oDSTemp.Tables[0].DefaultView.Table; // tried
oDSTemp.Tables[0] as well;

int StartRow = (1 * (int)PageResults) - (PageResults-1);
int PageRows = 0;
if (iTotalRows<PageResults)
PageRows=iTotalRows;
else
PageRows = iTotalRows - (StartRow);

if (PageRows>PageResults) PageRows=PageResults;

for (int iCount=0; iCount<PageRows; iCount++)
{
DataRow tmpRow =
oDS.Tables[0].DefaultView.Table.Rows[StartRow+iCount-1];
dtTemp.ImportRow(tmpRow);
}

uwgResults.DataSource = oDSTemp;
uwgResults.DataBind();

************
The items appear sorted inside the oDSTemp, which displays only a portion of
the DataSet, but not in the entire Dataset.
The oDSTemp shows the current page out of the total pages in the DataSet.

Thanks,

Aric Levin
Sounddogs.com

Nov 17 '05 #1
2 1409
Hi,

Refere to http://www.akadia.com/services/dotnet_filter_sort.html, I
think it will help you to solve it out. basically sorting dont change
the base DataTable it just effected DataView.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2
Hi,

Refere to http://www.akadia.com/services/dotnet_filter_sort.html, I
think it will help you to solve it out. basically sorting dont change
the base DataTable it just effected DataView.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #3

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

Similar topics

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...
0
by: Aric Levin | last post by:
I have a Dataset that I read from SQL Server. The dataset can contain more items that I want to display. When I try to resort the dataset it doesn't sort. Here is the Syntax. I am not sure what...
4
by: rodchar | last post by:
hey all, Regarding paging and sorting in a datagrid, is it better to: A: persist a dataset in session or B:
2
by: Carl Summers | last post by:
I have a table in an Access database that has no sort applied in Access. When I fill a dataset with data from that table (the entire one dimensional table) my dataset is sorted differently than...
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...
6
by: Nick | last post by:
I have a code that returns data in IList. My webGrid doesn't allow me to sort with IList returned, it say it only suports DataView, DataTable and DataSet, not IEnumerable. I don't know how to...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
1
by: Aeric | last post by:
I have read the following topic: sorting dataset and I am facing the same issue. I am designing a report. I have fill a dataset with the results from a query. From the results, I used to set...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.