GridView and multiple column sorting: is this a bug?

Discussion in 'ASP .Net' started by Eric, Jun 6, 2006.

  1. Eric

    Eric Guest

    I have a GridView control that I want to sort on multiple columns when I
    click a particular column. For example, I display Last name + ", " + First
    name in the first column and display id in the second column. When clicking
    on the first column, I want the GridView to sort on LastName and FirstName.
    Based on Microsoft's documentation of SortExpression property, all I have to
    do is to set SortExpression=LastName,FirstName on the first column. But when
    the GridView sorts the data, it only applies sorting direction to the second
    parameter of the SortExpression. In the above example, if I click on the
    first column, the GridView apparently always does sorting by LastName in
    ascending order, but the FirstName sort can be either ascending or
    descending (depending on whether I clicked the first column once or twice).
    I would expect the GridView to sort the entire sort expression on
    ascending/descending order, but it looks like the GridView does this only
    for the last parameter in the sort expression. Is this a bug or what?
     
    Eric, Jun 6, 2006
    #1
    1. Advertising

  2. Eric

    Brock Allen Guest

    If your data is a DataSet, DataTable or DataView, all that the grid is doing
    is passing in your SortExpression into the DataView's Sort property and it
    appends " DESC" when descending is requested.

    -Brock
    http://staff.develop.com/ballen


    > I have a GridView control that I want to sort on multiple columns when
    > I click a particular column. For example, I display Last name + ", " +
    > First name in the first column and display id in the second column.
    > When clicking on the first column, I want the GridView to sort on
    > LastName and FirstName. Based on Microsoft's documentation of
    > SortExpression property, all I have to do is to set
    > SortExpression=LastName,FirstName on the first column. But when the
    > GridView sorts the data, it only applies sorting direction to the
    > second parameter of the SortExpression. In the above example, if I
    > click on the first column, the GridView apparently always does sorting
    > by LastName in ascending order, but the FirstName sort can be either
    > ascending or descending (depending on whether I clicked the first
    > column once or twice). I would expect the GridView to sort the entire
    > sort expression on ascending/descending order, but it looks like the
    > GridView does this only for the last parameter in the sort expression.
    > Is this a bug or what?
    >
     
    Brock Allen, Jun 7, 2006
    #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. Thirsty Traveler

    Column sorting not working in GridView

    Thirsty Traveler, May 12, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    3,981
    Thirsty Traveler
    May 15, 2006
  2. Replies:
    2
    Views:
    15,919
  3. Keith G Hicks
    Replies:
    3
    Views:
    779
    Keith G Hicks
    Feb 18, 2008
  4. johnsonlim026
    Replies:
    0
    Views:
    945
    johnsonlim026
    Feb 27, 2010
  5. Tom Kirchner

    sorting by multiple criterias (sub-sorting)

    Tom Kirchner, Oct 11, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    483
    Michael Budash
    Oct 11, 2003
Loading...

Share This Page