Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Failed to load viewstate HttpException after calling FormView.UpdateItem(true);

Reply
Thread Tools

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

 
 
J055
Guest
Posts: n/a
 
      03-28-2007
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


 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      03-29-2007
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/subscripti...ult.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/subscripti...t/default.aspx.

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



This posting is provided "AS IS" with no warranties, and confers no rights.





 
Reply With Quote
 
 
 
 
J055
Guest
Posts: n/a
 
      04-04-2007
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors: Failed to load viewstate. & Validation of viewstate MAC failed. sck10 ASP .Net 6 09-01-2006 05:59 PM
Failed to load viewstate. The control tree into which viewstate... Josema ASP .Net Building Controls 2 05-22-2005 10:38 AM
Failed to load viewstate. The control tree into which viewstate... Josema ASP .Net Web Controls 0 05-09-2005 10:58 AM
System.Web.HttpException: The viewstate is invalid for this pageand might be corrupted Gvnn ASP .Net 2 10-18-2003 12:43 PM
System.Web.HttpException: Request timed out - [HttpException (0x80004005): Request timed out.] Steve ASP .Net 0 07-01-2003 12:11 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57