Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ObjectDataSource and GridView SortExpression with multiple columns problem

Reply
Thread Tools

ObjectDataSource and GridView SortExpression with multiple columns problem

 
 
Bogdan
Guest
Posts: n/a
 
      07-28-2009
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


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      07-31-2009
On Jul 28, 11:30*pm, "Bogdan" <(E-Mail Removed)> 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/libr...xpression.aspx
http://msdn.microsoft.com/en-us/libr...direction.aspx

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

Hope this helps
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding GridView Columns without Re-Firing ObjectDataSource Select =?Utf-8?B?SmF5IFBvbmR5?= ASP .Net 2 11-14-2007 10:03 AM
GridView ObjectDataSource hidden columns Steven Nagy ASP .Net 2 02-08-2007 09:05 AM
ASP.NET 2.0 / GridView / ObjectDataSource / Update / Missing Columns Urs Eichmann ASP .Net Web Controls 2 09-22-2006 09:11 PM
ObjectDataSource/GridView with dynamic columns Joel Krist ASP .Net Web Controls 0 05-18-2006 03:58 AM
GridView and SortExpression after Column Removed =?Utf-8?B?SmFtZXMgUm9zZXdlbGw=?= ASP .Net 1 02-27-2006 02:47 AM



Advertisments