Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Not re-adding dynamically generated controls

Author  Topic 

Billkamm
Posting Yak Master

124 Posts

Posted - 2006-02-21 : 13:09:19
I have a search page where if the results are found it returns a datagrid with the results. If no resutls are found it returns a literal control that outputs text saying "no results found".

The problem is when I do a search and get a datagrid then do another search and get no results I get an error on the second search because it says the viewstate does not have the same structure.

How can I fix this? (Error information below)


Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
   

- Advertisement -