DataSet Sorting Problem - HELP!

A

Aric Levin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top