. Net error: failed to load view status. The Control tree in which the view status is being loaded must match the control tree used to save the view status during the previous request. For example, when a control is added dynamically, the control added during the sending back must match the type and position of the control added during the initial request.
At system. Web. UI. Control. loadviewstaterecursive (Object savedstate)
At system. Web. UI. Control. loadviewstaterecursive (Object savedstate)
At system. Web. UI. Control. loadviewstaterecursive (Object savedstate)
At system. Web. UI. Control. addedcontrol (Control, int32 index)
At system. Web. UI. controlcollection. Add (control child)
At system. Web. UI. webcontrols. rowcontrolcollection. Add (control child)
At system. Web. UI. controlcollection. addat (int32 index, control child)
At system. Web. UI. webcontrols. rowcontrolcollection. addat (int32 index, control child)
At system. Web. UI. webcontrols. tablerowcollection. Add (tablerow row)
This error is caused by some controls. If the date control is dynamically loaded and the server returns the result, this error is triggered. If the date control is removed, it is normal.
Solution:
This problem occurs due to viewstate.
Add this. Page. enableviewstate = false;
There are a lot of discussions about this on the Internet, and it is easy to take a detour to look at other people's solutions. In fact, the above Code can solve the problem