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["SearchResu lts"];
Sort = Session["Sort"];
// Removes All Sorting Signs
int iTotalRows = Convert.ToInt32 (oDS.Tables[0].Rows.Count);
if (iTotalRows>0)
{
Session.Add("Cu rrentPage", 1);
Session.Add("To talPages",
Convert.ToInt32 ((oDS.Tables[0].Rows.Count - 1) / PageResults)+ 1) ;
Session.Add("To talRows", iTotalRows);
}
oDS.Tables[0].DefaultView.So rt = Sort;
Cache["SearchResu lts"] = oDS;
DataSet oDSTemp = oDS.Clone();
DataTable dtTemp = oDSTemp.Tables[0].DefaultView.Ta ble; // tried
oDSTemp.Tables[0] as well;
int StartRow = (1 * (int)PageResult s) - (PageResults-1);
int PageRows = 0;
if (iTotalRows<Pag eResults)
PageRows=iTotal Rows;
else
PageRows = iTotalRows - (StartRow);
if (PageRows>PageR esults) PageRows=PageRe sults;
for (int iCount=0; iCount<PageRows ; iCount++)
{
DataRow tmpRow =
oDS.Tables[0].DefaultView.Ta ble.Rows[StartRow+iCount-1];
dtTemp.ImportRo w(tmpRow);
}
uwgResults.Data Source = oDSTemp;
uwgResults.Data Bind();
************
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["SearchResu lts"];
Sort = Session["Sort"];
// Removes All Sorting Signs
int iTotalRows = Convert.ToInt32 (oDS.Tables[0].Rows.Count);
if (iTotalRows>0)
{
Session.Add("Cu rrentPage", 1);
Session.Add("To talPages",
Convert.ToInt32 ((oDS.Tables[0].Rows.Count - 1) / PageResults)+ 1) ;
Session.Add("To talRows", iTotalRows);
}
oDS.Tables[0].DefaultView.So rt = Sort;
Cache["SearchResu lts"] = oDS;
DataSet oDSTemp = oDS.Clone();
DataTable dtTemp = oDSTemp.Tables[0].DefaultView.Ta ble; // tried
oDSTemp.Tables[0] as well;
int StartRow = (1 * (int)PageResult s) - (PageResults-1);
int PageRows = 0;
if (iTotalRows<Pag eResults)
PageRows=iTotal Rows;
else
PageRows = iTotalRows - (StartRow);
if (PageRows>PageR esults) PageRows=PageRe sults;
for (int iCount=0; iCount<PageRows ; iCount++)
{
DataRow tmpRow =
oDS.Tables[0].DefaultView.Ta ble.Rows[StartRow+iCount-1];
dtTemp.ImportRo w(tmpRow);
}
uwgResults.Data Source = oDSTemp;
uwgResults.Data Bind();
************
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
Comment