DataSet Sorting Problem - HELP!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aric Levin

    #1

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





  • Natty Gur

    #2
    Re: DataSet Sorting Problem - HELP!

    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!

    Comment

    • Natty Gur

      #3
      Re: DataSet Sorting Problem - HELP!

      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!

      Comment

      Working...