Click here to Skip to main content
16,022,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i m getting this exception i dont where have i done mistake
actualy i have a gridview, in footer i have dropdown textbox and a button on button click i m adding the dropdownselected value and textbox text in list two times when i click on button it works but when i click third time i start getting this exception

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

if i turn off the enable viewstate then in mygrid only one time items are populated ...
Posted

1 solution

Do you add any controls dynamically (ie in code at runtime)? If so you must add the controls in the same way before the ViewState is loaded, it is best to do this when the page initialises.

See this[^] MSDN article for more guidance.
 
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