Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have added dynamic controls to the webpage its getting added on the selection of dropdownlist.
Its working fine: when user is entering data through that controls is getting stored properly into the database.
We are also allowing user to edit that data onclick of edit button which is added in the datalist but on click of update its throwing me error like

"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."


I am also providing Enableviewstate="false"
still its not working....
Please suggest solution.....

Thanks in advance....
Posted
Updated 7-Jun-13 3:10am
v5
Comments
Leo Chapiro 7-Jun-13 8:21am    
Have changed the veeeery loooong title of the question :)
ZurdoDev 7-Jun-13 8:53am    
Are you creating your controls in the OnInit event of the page?
Member 9996543 7-Jun-13 9:12am    
No...controls are creating on selection of dropdownlist
ZurdoDev 7-Jun-13 9:48am    
I have always had problems unless I create the items in the OnInit event. It is the proper event to create dynamic controls.
Prasad Khandekar 7-Jun-13 9:24am    
Hello,

Please have a look at the answers for a similar question (http://www.codeproject.com/Answers/601979/Dynamicallypluscreateplustextboxes#answer2).

Regards,

1 solution

Take a look at following links for resolution:
why-we-get-the-exception-failed-to-load-viewstate[^]
Failed to Load ViewState[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900