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

Problem with ViewState ?

Hey
I change backColor of linkButton in my Page_Load:
lbDoSth.BackColor = 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.HttpException: 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.Control.LoadViewStateRecursive(Objec t savedState) +484
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Page.LoadAllState() +558
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2238

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

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
Version:2.0.50727.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 4208
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**************@TK2MSFTNGP04.phx.gbl...
Hey
I change backColor of linkButton in my Page_Load:
lbDoSth.BackColor = 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.HttpException: 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.Control.LoadViewStateRecursive(Objec t savedState) +484
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Control.LoadChildViewStateByIndex(Ar rayList childState)
+195
System.Web.UI.Control.LoadViewStateRecursive(Objec t savedState) +425
System.Web.UI.Page.LoadAllState() +558
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2238

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

Version Information: Microsoft .NET Framework Version:2.0.50727.42;
ASP.NET Version:2.0.50727.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
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...
6
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...
2
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....
0
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...
3
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...
6
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...
9
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...
5
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...
6
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.