Problems with AutoPostBack=True
-
Hi ! I set several controls in my page and datagrid to have the property AutoPostBack=True. The problem is that every time I'm modifying as a user one of these controls (for instance, selecting another option from a DropDownList) the following error occur: [HttpException (0x80004005): 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.] Stack Trace: System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Page.LoadPageViewState() System.Web.UI.Page.ProcessRequestMain() What should I do for fixing it? Thanks
-
Hi ! I set several controls in my page and datagrid to have the property AutoPostBack=True. The problem is that every time I'm modifying as a user one of these controls (for instance, selecting another option from a DropDownList) the following error occur: [HttpException (0x80004005): 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.] Stack Trace: System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Control.LoadViewStateRecursive(Object savedState) System.Web.UI.Page.LoadPageViewState() System.Web.UI.Page.ProcessRequestMain() What should I do for fixing it? Thanks
Make sure if you're adding controls dynamically, that they are added before page load, and that they are always the same for the one page. Christian Graus - Microsoft MVP - C++