Click to See Complete Forum and Search --> : asp:GridView and defaulting to descending sort


G_Floppy
11-24-2010, 07:19 AM
I can't believe I can't Google the answer to this, but...

I'm trying to set up a sortable GridView that on first click on a header sorts that column in descending order. Ascending is the default, so I need to click each header twice to get to the descending I want.

Thanks in advance for help.

Greg

ryanbutler
11-24-2010, 09:38 AM
Looks like you need to append DESC on the sort expression of the column header.

http://netomatix.com/development/GridViewSorting.aspx

G_Floppy
11-24-2010, 09:44 AM
Simply adding DESC to the sortexpression property doesn't work. Well, it works once. Click on the header twice and you get an error because behind the scenes the second click tries to add DESC again, so you end up with two DESC's in the sortexpression. The only way I've been able to find is through something like the code included in the link you posted. I was hoping that there was a way to specify this behavior directly rather than having to code up special OnSort handlers.

Oh well...

Thanks!