473,394 Members | 1,956 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,394 software developers and data experts.

"Failed to load viewstate" When There Are No Dynamic Controls

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 control which one is visible based on buttons pushed. I can do single operations, but I get an error when I click SELECT on the GRIDVIEW, then UPDATE on the DetailsView then SELECT on the Gridview again.

I will have to send the code in a follow-on message, but here are the error details.

Thanks.

[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.]
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +355
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState) +142
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +303
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState) +142
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +303
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState) +142
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +303
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState) +142
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +303
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState) +142
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +303
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState) +142
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +303
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState) +142
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +303
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState) +142
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +303
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState) +142
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +303
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState) +142
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +303
System.Web.UI.Page.LoadAllState() +505
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2543
Sep 14 '06 #1
4 5116
Here is the code behind:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11.  
  12. public partial class Member_Administrator_Product_States : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.  
  17.     }
  18.   protected void cmdAdd_Click(object sender, EventArgs e)
  19.   {
  20.     pnlGrid.Visible = false;
  21.     DetailsView1.ChangeMode(DetailsViewMode.Insert);
  22.     pnlDetail.Visible = true;
  23.   }
  24.   protected void cmdSelect_Click(object sender, EventArgs e)
  25.   {
  26.     pnlGrid.Visible = false;
  27.     DetailsView1.ChangeMode(DetailsViewMode.Edit);
  28.     pnlDetail.Visible = true;
  29.   }
  30.   protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
  31.   {
  32.     if (e.Exception != null)
  33.     {
  34.       lblErrorMsg.Text = "Invalid data. Please correct and try again.";
  35.       e.ExceptionHandled = true;
  36.       e.KeepInEditMode = true;
  37.     }
  38.     else if (e.AffectedRows == 0)
  39.       lblErrorMsg.Text = "Another user updated that category. Please try again.";
  40.   }
  41.   protected void DetailsView1_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
  42.   {
  43.     if (e.Exception != null)
  44.     {
  45.       lblErrorMsg.Text = e.Exception.Message;
  46.       e.ExceptionHandled = true;
  47.     }
  48.     else
  49.       if (e.AffectedRows == 0)
  50.         lblErrorMsg.Text = "Another user updated that category. Please try again.";
  51.   }
  52.   protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
  53.   {
  54.     if (e.Exception != null)
  55.     {
  56.       lblErrorMsg.Text = "Invalid data. Please correct and try again.";
  57.       e.ExceptionHandled = true;
  58.       e.KeepInInsertMode = true;
  59.     }
  60.     else if (e.AffectedRows == 0)
  61.       lblErrorMsg.Text = "Another user updated that category. Please try again.";
  62.   }
  63.   protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)
  64.   {
  65.     switch (e.CommandName) { 
  66.       case "Cancel":
  67.       case "Update":
  68.       case "Insert":
  69.         pnlGrid.Visible = true;
  70.         pnlDetail.Visible = false;
  71.         break;
  72.       default:
  73.         break;
  74.     }
  75.   }
  76. }
Sep 14 '06 #2
I am having trouble sending the script. When I attempt to post it, I get the following message even though there are no image tags in my script or my signature. I am a first-time poster, so anything is possible.
Sep 14 '06 #3
You have included too many images in your signature or in your previous post. Please go back and correct the problem and then continue again.

Images include use of smilies, the vB code [img] tag and HTML <img> tags. The use of these is all subject to them being enabled by the administrator.
Sep 14 '06 #4
I have re-posted this in the appropriate Web Developers forum where it belongs. I apologize if you read this far because I am new to your forum.
Sep 14 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: keefah | last post by:
Hi, I can't seem to get past this problem, though I've tried multiple examples off the web. I've registered integrated Crystal (VS.NET 2003 Pro). I've made sure the assemblies are all there. I've...
2
by: Karun Karunakaran | last post by:
Hi, I am using the Crystal Enterprise .NET assemblies to generate and display a crystal report in a webform. This report connects to an SQL server (running locally) using a specific username and...
2
by: Ravi J | last post by:
I am trying to load Microsoft Word and create a document in ASP.NET (C#). But the call to application creation 'Word._Application app = new Word.ApplicationClass();' takes quit a bit of time, and...
1
by: Jonas Auken | last post by:
hi, I have a repeater which dynamically loads another usercontrol throught databinding: OnClick: DataBind() rptProduct_ItemDataBound: ViewSmall _viewSmall = (ViewSmall)...
1
by: Roy | last post by:
Hey all, I have a VB App which uses the bundled version of Crystal Reports for VS.NET 2003. It works fine in when I run it using VS *but* when I deploy it anywhere (including the development PC...
2
by: Jeff_Mac | last post by:
Hi there. I'm a bit of a newbie, and I would appreciate any help that anyone can give me on an error I'm getting with Crystal Reports. Every time I attempt to view a report using the Crystal...
1
by: aaaaaa | last post by:
running a crystal (v10) reporting app on a virtual web server and getting the "Validation of viewstate MAC failed...." error when opening the crystal viewer. Any help please!!!
0
by: Radu | last post by:
Hi. I have finished a web-site - and it runs fine on my dev machine. I have deployed it onto the server, and now I have this (which, by the way, doesn't seem to happen all the time - sometimes I...
5
by: SpaceMarine | last post by:
hello, when my page attempts a Telerik RadGrid row insert (AJAX enabled) my page throws this exception: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.