views:

334

answers:

2

I have a grid view with AllowSorting set to true. I get an event onsorting when a sortable header is clicked on. the handler has a parameter "GridViewSortEventArgs e" which has a SortDirection property on it. regardless of how many times you click on the same heading, the SortDirection is always Ascending. I think I'm missing something, like a way to tell the grid "now you are sorted based on column one and in ascending order", so that next time the grid sees a click on the "column one" heading, it decides to go descending.

any help appreciated. Cheers, Ali

A: 

how about Google for an answer before come here?

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

http://weblogs.asp.net/scottgu/archive/2006/02/11/437995.aspx

balexandre
Why didn't I think of google???hmmm, maybe, because I trust on stack overflow I can always find a friendly answer?mate, I did look at those posts, they are HACKs, I'm looking for a solution. one thing I didn't find, was scott gu post saying this is the correct approach...
Ali Shafai
ohh, you need someone to let you know, yes do this! "Mate" try it, use it, explore the code and learn something with your errors! and Google 1st before coming here, don't make SO a Google alike website, it's not it's propose!
balexandre
Well, here's another hack:http://aspnet.4guysfromrolla.com/articles/020608-1.aspx
chris
Point taken. thanks master.
Ali Shafai
maybe you missed my first link when it says: "There seems to be a bug in GridView sorting implementation. Value of SortDirection is always set to "Ascending"." Don't wait for an answer, try yourself, do some self-improving, that's the better way to never do the same mistake twice.
balexandre
A: 

Thanks everyone, I listened to balexandre and took the viewState approach. I think I shouldn't be doing this, but there seem to be no better way atm and I have to ship today...

thanks again, great community. Cheers, Ali

Ali Shafai
The ViewState approach is the correct way to go. This feature does NOT work with any datasource other than an asp:SqlDataSource object, according to my research.
Bryan