views:

154

answers:

1

I have a gridview that is populated on the Page_Load event if !PostBack is true.

The gridview has several column, each header template has a custom control that I'm using to sort the data in a more efficient way than what the ASP.NET gridview offers.

These custom controls have an OnSort event, I have tried defining them in the markup (was always null after postback) and hooking them up each time the page is loaded (now works).

Basically on a page postback, the ViewState for the custom controls in the gridview are being 'lost'. This is a problem as I have a Sort Direction field that toggles between Asc and Desc, and I rely heavily on the ViewState to remember the last value.

Does anyone know what I might be doing wrong here? Or how I could change my code to keep the ViewState.

Cheers

A: 

Well, if you're not paging, I would frankly forget all about using postbacks and viewstate to sort anything since it's so easy to use the JQuery tablesorter. It takes all of the effort out of what you're doing, and at the same time provides a much smoother and faster interface for your users.

Dave Markle
I'd love to use JQuery but I am bound to the technologies already in place (basically just ASP.NET/C#.Net etc). I am using paging, it is handled in a custom control and thus I have created sorting controls.
Adam Witko