473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
Mar 28 '07 #1
2 5277
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.

Mar 29 '07 #2
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
Apr 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
4
by: sklett | last post by:
I have 2 dropdownlist on a page. They have ViewState = true. After I submit to the page, the selection in the DropDownList is lost. I set a break in the Page_Load event to make sure that I...
5
by: Christian Stapfer | last post by:
After switching from Python 2.3 to 2.4 (Enought), PIL throws an exception that did not occur formerly (under Python 2.3) when executing ImageFont.truetype(font, size) where font =...
4
by: scottcly | last post by:
I have a simple editor with a Gridview and a DetailsView. The Gridview handles DELETE and the DetailsView handles UPDATE and ADD. A panel around each one and some minor event handling is used to...
2
by: sck10 | last post by:
Hello, I have a web page that has a GridView and a FormView, each in its own panel. The GridView shows a list of records in a database. When a row in the GridView is selected the FormView...
1
by: Rich | last post by:
Hi, I'm using a DetailsView in asp.net 2.0 and C#. After the UpdateItem(true) is hit, I want to redirect the page to the next page. The code won't do this though for some reason. As soon as the...
5
by: Just Me | last post by:
I have a simple page and was trying to test viewstate for a textbox. in my page_load event If not ispostback then textbox1.text="hello" end if
4
by: DavidF | last post by:
Hi, I'm having a problem with viewstate encryption on one of my websites. To encrypt the viewstate, I'm using the following lines in my web.Config file: <pages theme="Default"...
1
by: chris | last post by:
I have an ASP.NET web page which contains a dynamically generated table. The user checks a checkbox in one or more rows and then clicks an OK button which then passes the selected row numbers to a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.