DataGrid Sorting - bidirectional

Discussion in 'ASP .Net Datagrid Control' started by Snig, Nov 27, 2003.

  1. Snig

    Snig Guest

    Hi,

    I want to sort the DataGrid according to the number of clicks of mouse on
    the column-header link.
    e.g.
    if user clicks on the header once - it will be sorted ASC
    if the header is double-clicked - it will be sorted DESC

    It is not exactly toggling the sorting-order. I have seen a lot of messages
    and articles in the web about toggling the sort order (like first time click
    will generate ASC sort, next time click will generate DESC sort and so on).

    But my requirement is how to catch single/double-click of the mouse on the
    column header and fixing the sort order accordingly.

    Any ideas ?

    Thanx
    Snig.
    Snig, Nov 27, 2003
    #1
    1. Advertising

  2. If you are looking for client side sorting of data in datagrid, check the
    example from
    http://www.v4cnet.com/

    Rgds
    Sukesh

    "Snig" <> wrote in message
    news:eT3Yn$...
    > Hi,
    >
    > I want to sort the DataGrid according to the number of clicks of mouse on
    > the column-header link.
    > e.g.
    > if user clicks on the header once - it will be sorted ASC
    > if the header is double-clicked - it will be sorted DESC
    >
    > It is not exactly toggling the sorting-order. I have seen a lot of

    messages
    > and articles in the web about toggling the sort order (like first time

    click
    > will generate ASC sort, next time click will generate DESC sort and so

    on).
    >
    > But my requirement is how to catch single/double-click of the mouse on the
    > column header and fixing the sort order accordingly.
    >
    > Any ideas ?
    >
    > Thanx
    > Snig.
    >
    >
    [ MVP ] Sukesh Ashok Kumar, Jan 3, 2004
    #2
    1. Advertising

  3. Snig

    Prodip Saha Guest

    Very simple:
    Add a private variable on the page/class:
    private static string SortExpression="";

    In your sortcommand event handler add the following codes:

    if(SortExpression==e.SortExpression.ToString()) //Change the sort order to
    DESC

    {

    SortExpression = e.SortExpression.ToString() +" DESC";

    }

    else //Change the sort order to ASC

    {

    SortExpression = e.SortExpression.ToString();

    }

    try

    {

    //Bind the Grid Data

    BindGridData();


    }

    catch(Exception ex)

    {

    throw ex;

    }

    Prodip Saha

    "[ MVP ] Sukesh Ashok Kumar" <> wrote in message
    news:...
    > If you are looking for client side sorting of data in datagrid, check the
    > example from
    > http://www.v4cnet.com/
    >
    > Rgds
    > Sukesh
    >
    > "Snig" <> wrote in message
    > news:eT3Yn$...
    > > Hi,
    > >
    > > I want to sort the DataGrid according to the number of clicks of mouse

    on
    > > the column-header link.
    > > e.g.
    > > if user clicks on the header once - it will be sorted ASC
    > > if the header is double-clicked - it will be sorted DESC
    > >
    > > It is not exactly toggling the sorting-order. I have seen a lot of

    > messages
    > > and articles in the web about toggling the sort order (like first time

    > click
    > > will generate ASC sort, next time click will generate DESC sort and so

    > on).
    > >
    > > But my requirement is how to catch single/double-click of the mouse on

    the
    > > column header and fixing the sort order accordingly.
    > >
    > > Any ideas ?
    > >
    > > Thanx
    > > Snig.
    > >
    > >

    >
    >
    Prodip Saha, Jan 5, 2004
    #3
    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. John Saunders
    Replies:
    1
    Views:
    334
    Billy Porter
    Aug 12, 2003
  2. Snig
    Replies:
    2
    Views:
    446
    Infant Newbie
    Nov 27, 2003
  3. mark

    datagrid bidirectional sorting

    mark, Jun 15, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    1,961
    Ashish M Bhonkiya
    Jun 15, 2004
  4. Manfred Balik
    Replies:
    12
    Views:
    6,562
    Marc Guardiani
    Sep 10, 2006
  5. Sean

    BiDirectional Sorting

    Sean, Feb 5, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    125
Loading...

Share This Page