locked
unable to load view state. GridViewcontrol on dyanamic loaded usercontrol RRS feed

  • Question

  • User785108310 posted

    hi,

    I am working on vast project. In which user have to fill large form for that i am using tabpanels. and depend on user selection tha usercontrols get loaded in 3rd tabpanel. In my complicated usercontrol. iam using GridView with edit update delete links.

    when i am inserting any new row and try to update it I got following error

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

    please help me out. I unable to move forward. plz plz help me.

    Thursday, October 25, 2012 7:59 AM

All replies

  • User960609757 posted

    Hi,

    dynamic controls would need to be created on every request.

    E.g if you create them initially in a postback event such as button click, you'd need to recreate them on next Page loading so that they'd exist in the Controls  collection. ViewState would work when you'd have dynamic control instantiation in order. 

    You should be using a GridView, DataGrid, DataList, Repeater or such. But if you really have to add the controls "manually", then you have to add them on every page request, and in the exact same order. If you do this, then the controls will load their ViewState as well as the values posted from the form. This will make the new values available in the Text or Checked properties, and it will allow the controls to raise events when these values change.

    check this url ,

    http://aspadvice.com/blogs/joteke/archive/2006/01/06/14568.aspx


    Thursday, May 9, 2013 1:01 AM