Failed to load viewstate. The control tree into which viewstate is being loaded Failed to load viewstate. The control tree into which viewstate is being loaded asp.net asp.net

Failed to load viewstate. The control tree into which viewstate is being loaded


What is important when you are adding controls dynamically is on which event you are adding them.

If you added controls on events that occur after load, they will be part of the viewstate you send to the client.

You will have to add those controls again before LoadViewState is called.

If you run into cases where the decision of which controls to add is itself stored in the ViewState or the value of a control, then remember even before the ViewState is loaded, this data is available in Request.Params

Refer the asp.net page life cycle

Page life cycle


I just added EnableViewState="false" to my page placeholder and its gone. Hope it works for u as well.


This Error Mainly Occurs during View state Change: From One Template To other Template like in case of Item Template, Edit Item Template, in Controls like Form View, List Views, Detail View, Grid View in ASP .net (all frameworks);

While Changing from control states say Item Template ---> Edit Template the followings were going to alter

1) Controls will change (its ID & states)

2) Its Positions will change.

While Transformation of view if any post back occurs you will get Error as

Failed to load viewstate. The control tree into which viewstate is being loaded....

if you are using separate control for data-binding like (button,link_button_Image_button events) you will get this error reported !

To avoid this error >>> Once state changes from one template to other within method you call data source binding ( Don't call during click or any post backing events ).