views:

1759

answers:

1

I selection page that has a gridview that presents the user with a list of data items that they can click on to "drill into" - redirecting them to the data maintenance page.

Because the list can get long, we have a series of check boxes and drop-down lists at the top that act as filters.

We just implemented an UpdatePanel with an UpdatePanelAnimationExtender so that when the page made long trips back to the databse, they would get a nice "Processing..." pop up.

Problem is, this seems to break the viewstate on the drop-down lists and check boxes. Now, when they go to the 'detail page' and hit the BACK button to get back to the 'selection' page - the selected values in the checkboxes and drop-downlists are back to their initial defaults. The lists are still populated, but they 'forgot' what they had when the user clicked to the data maintenance page.

I took out the .aspx code for the UpdatePanel and the animation extended and retested and everything worked perfectly. So, apparently, the UpdatePanel and/or the AnimationExtender doesn't play nice with the viewstate.

Is there a way I can stop the UpdatePanel's actions from, in effect, zeroing out the '.SelectedValue" properties?

+1  A: 

First I would remove your "filtering" controls from the UpdatePanel. Assuming that the data for these controls are valued on Page_Load, they do not need to be refreshed every time the filter is applied to the GridView. Only the GridView is being refreshed, so it's likely that it is the only control that should be contained in the UpdatePanel.

Each of the filtering controls can be added as a trigger for updating the UpdatePanel by declaring them in the section of the UpdatePanel control. Or, if the filtering process is invoked by a "submit" like button, that would be the control to be declared in the section. This should retain the values of the filtering controls in the browser's cache.

You can also try Nikhil Kothari's UpdateHistory control (Nikhil has an excellent blog, btw) which will save the contents of the UpdatePanel as history entries in the browser's history list.

EDIT: FYI, UpdatePanel does not "kill" ViewState. The ViewState is transmitted back and forth via the UpdatePanel's update mechanism, often causing performance issues if the ViewState is excessively large. What you're seeing is the browser's history cache not storing the values that have been updated on successive callbacks. The above techniques should help.

Bob Mc
Well, I've managed to use your technique (getting the controls out of the UpdatePanel and adding them as AsyncPostBackTrigger items in the Triggers collection) to keep from wiping out the selected values in the drop-down lists. Unfortunately, when I hit the trigger, even though the dropdown lists still have their members and the selected item still appears in the 'textbox' part, the "SelectedIndexValue" has reverted to 0 and the display routine's filters don't work properly.
David
...and it turns out that there was something in the code clearing and re-populating the drop-down lists, hence the reason the selected index was resetting. Now that it's down to an application programming problem, I'm marking this 'answered'.
David
Glad I could help David. Thanks.
Bob Mc
The real 'gotcha' that I have to deal with is, as you stated, the browser history cache not storing the stuff in the UpdatePanel. I've managed to get things working "ok" but not 100% (fix one undesired behavior and the 'old' cache is displayed, fix that and the drop-down lists are perpetually one-refresh behind in values) and I suspect I'll need that UpdateHistory control to fix things 100%
David