Re: ObjectDataSource and GridView SortExpression with multiple columns problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Jul 28, 11:30 pm, "Bogdan" <bog...@xxxxxxxxxxx> wrote:
Hi,

I've spent some time reading articles on gridview sorting when sort
expression consists of multiple columns.  I have to say that I'm as confused
as ever.

Could someone please help me out on this one?  What do I need to do in order
to utilize GridView's auto-sorting and be able to set the sort expression to
multiple columns?

Some articles mentioned that if I set SortExpression="column1,column2" and
try to sort in descending order then GV passes  an expression of the
following format to the data source object: "column1, column2 DESC" and this
is why descending sort is never applied to the first column?  Could someone
please confirm this?  Is there an 'official' doc from MS that deals with it?

If the above is true, is there a workaround/solution?

I'd appreciate _any_ suggestions.
Thanks,
Bogdan

Hi Bogdan

This is true. The SortExpression property is a string and could
contain a comma-separated list of the fields by which to sort. The
SortDirection property used a SortDirection datatype and could contain
one of two SortDirection values: Ascending or Descending. So, when
GridView has multiple columns to sort, then SortExpression property
contains a list and SortDirection just one possible value and a
GridView generates something like this

"FirstName, LastName DESC"-- where first column is still sorted in
ascending order.

I found this a bit stupid but this is the way it works

MSDN:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.sortexpression.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.sortdirection.aspx

Here's an example of how to do a workaround
http://aspalliance.com/666_Extending_the_GridViews_Sorting_Capabilities.all

Hope this helps
.



Relevant Pages

  • Re: Need help with Listview sort
    ... So I take it that there is no way to substitute the built in function (at ... > Except understand that the listview will only sort on one column at a ... > not on multiple columns. ...
    (microsoft.public.vb.controls)
  • Dataview Sort
    ... Apparently CF doesn't support sorting a dataview on multiple columns. ... I am using the Dataview to sort my data before binding it to a combo. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Sorting 1, 1A, 2, 2A, 3, 4, 4A, 4B . . .
    ... I have a spreadsheet with multiple columns and the ... column that I want to sort by contains sheet numbers. ... with two sorting options). ...
    (microsoft.public.excel.misc)
  • Re: splitting 1 column of data into multiple columns
    ... > I am trying to split up some data into multiple columns with part of the data ... > This needs to be done so I can sort by using the 2nd set of numbers. ... Dave Peterson ...
    (microsoft.public.excel.setup)
  • Re: Sorting when the page is loaded the first time
    ... the value 'Height' in the SelectParameters ... My problem is that the first time the page is loaded the sort paramter is ... passed a zero lenght string. ... So the gridview is not sorted. ...
    (microsoft.public.dotnet.framework.aspnet)