473,700 Members | 2,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with ViewState ?

Hey
I change backColor of linkButton in my Page_Load:
lbDoSth.BackCol or = Color.Red;

But I have multiView on this page. On one of the views I have detailsView.
When I add a new row a set Visible = false on this detailsView. And rebound
appropriate gridView. Then I press the button and I have exception:

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.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.Http Exception: 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.

Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[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.C ontrol.LoadView StateRecursive( Object savedState) +484
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.P age.LoadAllStat e() +558
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +2238

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:2.0.507 27.42; ASP.NET
Version:2.0.507 27.42

How should I persist the backColor of the linkButton ? The problem is only
after Inser/Edit in detailsView and re-bound of controls.
Jarod

May 31 '06 #1
2 4232
Turn off the multiview panel as late in the stack as is possible. I would
have to look at where viewstate is applied, but the easiest is to use an
event after viewstate is applied before you make something invisible.

--
Gregory A. Beamer

*************** *************** *************** ****
Think Outside the Box!
*************** *************** *************** ****
"Jarod" <bl*****@NOSPAM .gazeta.pl> wrote in message
news:Or******** ******@TK2MSFTN GP04.phx.gbl...
Hey
I change backColor of linkButton in my Page_Load:
lbDoSth.BackCol or = Color.Red;

But I have multiView on this page. On one of the views I have detailsView.
When I add a new row a set Visible = false on this detailsView. And
rebound appropriate gridView. Then I press the button and I have
exception:

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.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.Http Exception: 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.

Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[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.C ontrol.LoadView StateRecursive( Object savedState) +484
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.C ontrol.LoadChil dViewStateByInd ex(ArrayList childState)
+195
System.Web.UI.C ontrol.LoadView StateRecursive( Object savedState) +425
System.Web.UI.P age.LoadAllStat e() +558
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +2238

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:2.0.507 27.42;
ASP.NET Version:2.0.507 27.42

How should I persist the backColor of the linkButton ? The problem is only
after Inser/Edit in detailsView and re-bound of controls.
Jarod

May 31 '06 #2
> Turn off the multiview panel as late in the stack as is possible. I would
have to look at where viewstate is applied, but the easiest is to use an
event after viewstate is applied before you make something invisible.


Can you give me more details best with examples how to do it ? Because I've
never turned off anything from stack... and it sounds a bit tricky for me.
Event after viewstate was applied... ok, but what's the event name and on
what object use it ?
Jarod

May 31 '06 #3

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

Similar topics

4
12692
by: Stephen | last post by:
I have the following code working in order to create an array list and populate a datagrid however everytime i click my button the first item in the array and the first row in the datagrid are overwritten. I think this is some sort of post back problem but i can't seem to figure out how to solve it. Can someone help me with this please. private ArrayList addresses; private void Page_Load(object sender, System.EventArgs e) {
6
7014
by: Robin Bonin | last post by:
In my user contol I am creating a set of dropdownlists. Each list is created based on input from the other lists. The problem I am having is setting the selected index on the lists. If someone changes box1, I want to set the selected index in box2 = 0. When I do this, I dont get an error, but when the page loads, it still has the selected value and not 0. It seems that it is getting the selected value from the viewstate
2
1606
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview. The following control simply responds to a sort request and/or a pageing reqeust with an empty table (header only). Any ideas ? Code behind : namespace OakTree.data {
0
1640
by: Mike Hofer | last post by:
Hi everyone. I could really use some help. First, the backstory: ===================== I *really* need a 3-state checkbox for my ASP.NET application. Specifically, I need one that lets me set the image for the checkbox portion so that the control conforms to my site's visual style, and that lets me set the style for the text in both the enabled and disabled states. As you might expect, I couldn't find one. So I decided to roll my own.
3
2341
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users page. So whenever the Admin person comes to know about the new category in the market he will be adding as different Sub-Categories for example ABAP, BDC etc..etc.. on every click event as Checkboxes. And these controls(checkboxes) should remain...
6
2857
by: hlubocky | last post by:
I thought I had a good grasp of the problem related to dynamically creating controls, but it appears that as my application grew in complexity, the problem has resurfaced. As I understand it, in order for a dynamically created control to persist its state, it needs to be created and loaded into the page control hierarchy before the viewstate is loaded. The proposed solution, and that which I have been using, has been to create all of...
9
2720
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
5
2205
by: Slim | last post by:
i have a simple page, with one button button1. when click it creates a new button button 2 and adds a event handler to it. but when button 2 is clicked nothing happens, why? Partial Class test_buttons Inherits System.Web.UI.Page Dim bt2 As Button
6
2292
by: thanigaimani83 | last post by:
Hi guys. i can explain for my doubt with example.see.my table have multiple type of employee details like as Mangemment,Programmer,Designers,Accountants,ContractEmployees.Each type of department having many employee details.Now my drop down list having types of department names like that above types of department names..if i select any one type of department data wil be display in gridview format .gridview data column as employee...
0
8644
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9214
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9074
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8924
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6560
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5902
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3088
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.