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. Advertisements

  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 Allen, Jun 7, 2006
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.