Search This Blog

Wednesday, November 24, 2010

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

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

When you are using FormView with ItemTemplate , InsertItemTemplate and EditItemTemplate and you click any event like save, update or delete. After this you click on any postback control then you may get the above exception.

Cause: All template FormView may have different control definition e.g. ItemTemplate does not match control definition with IsertItemTemplate or EditItemTemplate(number of controls or mismatch of control ids')

Solution: Try to keep same control definition in all template

Note: Try to not include ItemTemplate in your FormView

No comments:

Post a Comment