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
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