Click here to Skip to main content
15,120,883 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....
Updated 7-Jun-13 4:10am
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

Please have a look at the answers for a similar question (


1 solution

Take a look at following links for resolution:
Failed to Load ViewState[^]

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