Failed to load viewstate HttpException after calling FormView.UpdateItem(true);

Discussion in 'ASP .Net' started by J055, Mar 28, 2007.

  1. J055

    J055 Guest

    Hi

    I need some help with this one. If I add this LinkButton Command event I get
    an 'System.Web.HttpException: Failed to load viewstate' on the second
    postback. It only occurs when FormView1.UpdateItem(true) is called. The page
    posts back OK. When I do a second PostBack I get the error.

    protected void LinkButtonPrevNext_Command(object sender,
    CommandEventArgs e)
    {
    if (FormView1.CurrentMode == FormViewMode.Edit)
    {
    FormView1.UpdateItem(true);
    }
    //...other bits
    }

    As far as I know I am not loading any Controls dynamically. I'm finding it
    almost impossible to debug and find out why the controls are different.

    What's the best way to isolate the problem?

    Thanks
    Andrew
    J055, Mar 28, 2007
    #1
    1. Advertising

  2. Hello Andrew,

    From your description, you're getting "System.Web.HttpException: Failed to
    load viewstate...." exception when manually use a button to trigger the
    FormView's UpdateItem command, correct?

    According to the code logic you mentioned, I have performed some simple
    test on my local side and it seems a very simple and typical FormView
    editing/updating webform can not quite repro the exact error behavior. My
    test result is as below:

    I use a FormView to edit and update a very simple table in SQL Server, the
    autogenerated edit/update interface(inside formview works well).

    And then I put a button on the webform(out side of the formview) and add
    code to manually update the FormView item:

    protected void btnOutUpdate_Click(object sender, EventArgs e)
    {
    if (FormView1.CurrentMode == FormViewMode.Edit)
    {
    FormView1.UpdateItem(true);
    }
    }

    it also works without any problem. Therefore, I think the problem is
    likely specific to the data table or anything else on the webform. I
    suggest you try simplify the page step by step to isolate the cause.

    If you have any new finding or anything we can help, please feel free to
    post here.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Mar 29, 2007
    #2
    1. Advertising

  3. J055

    J055 Guest

    Hi Steven

    I solved the problem by adding FormView1.DataBind below the UpdateItem
    method. My code creates and event when the UpdateItem occurs to tell the
    Parent page to switch to another View in a MultiView control. If I don't
    change the view then the error doesn't occur.

    The MultiView control contains 4 views with their own user control. I'm
    still not sure why DataBinding would solve the problem and why the error
    occurs when the MultiView.ActiveViewIndex is changed.

    Thanks
    Andrew
    J055, Apr 4, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve
    Replies:
    0
    Views:
    5,331
    Steve
    Jul 1, 2003
  2. sck10
    Replies:
    6
    Views:
    913
    sck10
    Sep 1, 2006
  3. sck10
    Replies:
    2
    Views:
    1,089
    sck10
    Nov 23, 2006
  4. Rich
    Replies:
    0
    Views:
    279
  5. bdb112
    Replies:
    45
    Views:
    1,341
    jazbees
    Apr 29, 2009
Loading...

Share This Page