Sort by two columns in grid

Discussion in 'ASP .Net' started by Sehboo, Sep 1, 2007.

  1. Sehboo

    Sehboo Guest

    I have three columns in grid, name, division and terminal. What I
    want is that when I click on name header then I want the grid to sort
    by name, but when I click on division then it should sort by division,
    and then name. This way, all the poeple in each division will be
    sorted in alphabatical order. How do I achieve this? I am on VS2003.

    Thanks
     
    Sehboo, Sep 1, 2007
    #1
    1. Advertising

  2. You can specify both columns in the SortExpression property and override
    DataGrid.OnSortCommand method. If only one column name is passed in the Sort
    Expression property of the event argument, call the default event handler.
    If two columns are passed, implement your own sorting. You may re-populate
    the datasource with a modified sql or use a DataView that allows specifying
    multiple columns for sorting.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Sehboo" <> wrote in message
    news:...
    >I have three columns in grid, name, division and terminal. What I
    > want is that when I click on name header then I want the grid to sort
    > by name, but when I click on division then it should sort by division,
    > and then name. This way, all the poeple in each division will be
    > sorted in alphabatical order. How do I achieve this? I am on VS2003.
    >
    > Thanks
    >
     
    Eliyahu Goldin, Sep 2, 2007
    #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. helpful sql
    Replies:
    0
    Views:
    824
    helpful sql
    May 19, 2005
  2. Replies:
    5
    Views:
    606
  3. GenxLogic
    Replies:
    3
    Views:
    1,294
    andrewmcdonagh
    Dec 6, 2006
  4. jonefer
    Replies:
    0
    Views:
    782
    jonefer
    May 21, 2007
  5. Navin
    Replies:
    1
    Views:
    710
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page