Sort Routine Problem

Discussion in 'ASP .Net Datagrid Control' started by Tom Carter, Jan 19, 2004.

  1. Tom Carter

    Tom Carter Guest

    I have created a datagrid that has edit/update/cancel links and whose
    header is sortable. I have one glitch which I hope sounds familar to
    someone ...

    I click the edit butoon and the textboxes are populated with data
    from a different record than the record which I selected. This
    problem occurs only after I sort the data.

    What am I missing???

    -- here's the code:

    private void masterDataGrid_SortCommand(object source,
    System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
    {
    //Logic Handles Bi-Directional Sorting using SortHandler Hidden
    Label
    switch (SortHandler.Text.EndsWith(" ASC"))
    {
    case true :
    SortHandler.Text = e.SortExpression.ToString () + " DESC";
    break;
    case false:
    SortHandler.Text = e.SortExpression.ToString () + " ASC";
    break;
    }

    dv.Sort = SortHandler.Text;
    this.masterDataGrid.DataSource = dv;
    this.masterDataGrid.DataBind();

    }

    -- heres the edit routine:
    private void masterDataGrid_EditCommand(object source,
    System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    this.masterDataGrid.EditItemIndex = e.Item.ItemIndex;
    this.masterDataGrid.DataBind ();
    }
    Tom Carter, Jan 19, 2004
    #1
    1. Advertising

  2. Tom Carter

    Tom Carter Guest

    Re: Sort Routine Problem Resolved

    Hi Team,

    The problem is solved. I extrapolated the answer based on another
    online answer. Essentially I needed to reset the Sort expression
    before binding the data on each postback of the page.

    i.e.
    this.masterDataGrid.DataSource = dv;
    dv.Sort = SortHandler.Text;
    this.masterDataGrid.DataBind ();

    Thanks anyhow -
    --
    ~~~~~~~~~~~~~
    Tommie Carter
    --

    (Tom Carter) wrote in message news:<>...
    > I have created a datagrid that has edit/update/cancel links and whose
    > header is sortable. I have one glitch which I hope sounds familar to
    > someone ...
    >
    > I click the edit butoon and the textboxes are populated with data
    > from a different record than the record which I selected. This
    > problem occurs only after I sort the data.
    >
    > What am I missing???
    >
    > -- here's the code:
    >
    > private void masterDataGrid_SortCommand(object source,
    > System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
    > {
    > //Logic Handles Bi-Directional Sorting using SortHandler Hidden
    > Label
    > switch (SortHandler.Text.EndsWith(" ASC"))
    > {
    > case true :
    > SortHandler.Text = e.SortExpression.ToString () + " DESC";
    > break;
    > case false:
    > SortHandler.Text = e.SortExpression.ToString () + " ASC";
    > break;
    > }
    >
    > dv.Sort = SortHandler.Text;
    > this.masterDataGrid.DataSource = dv;
    > this.masterDataGrid.DataBind();
    >
    > }
    >
    > -- heres the edit routine:
    > private void masterDataGrid_EditCommand(object source,
    > System.Web.UI.WebControls.DataGridCommandEventArgs e)
    > {
    > this.masterDataGrid.EditItemIndex = e.Item.ItemIndex;
    > this.masterDataGrid.DataBind ();
    > }
    Tom Carter, Jan 20, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kamilche

    CODE: Generic Sort Routine

    Kamilche, Aug 19, 2004, in forum: Python
    Replies:
    1
    Views:
    295
    Andrew Henshaw
    Aug 23, 2004
  2. rkk
    Replies:
    9
    Views:
    811
    CBFalconer
    Sep 24, 2006
  3. PatLaf

    AspNet DataGrid won't fire sort routine

    PatLaf, Oct 29, 2003, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    185
    Alvin Bruney
    Oct 30, 2003
  4. Navin
    Replies:
    1
    Views:
    688
    Ken Schaefer
    Sep 9, 2003
  5. Arthur

    Perl Sort Routine

    Arthur, Feb 12, 2004, in forum: Perl Misc
    Replies:
    2
    Views:
    94
    Paul Lalli
    Feb 12, 2004
Loading...

Share This Page