failed to load viewstate

A

Ariel Gimenez

Hello,
Can someone helpme?
I have a datagrid in wich im using column templates for the edit command,
with comboboxes.
The datagrid works fine for the first time i execute the edit command but
the second time it gives me the following error...

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.

any help will be appreciated
Thanks in adfance
Ariel Gimenez
 
F

Felbrigg

The message is hinting that dynamic controls in the grid must be reloaded
during postback.

It is comman practice ( and i assume your doing it ) to put your databinding
inside "if(IsPostBack==false)" which is fine for the data. But if you have
dynamicly added controls, these have to be recreated for every postback.
 
M

Mohamoss

Hi Ariel
This problem probably happens because you are deleting controls form
those you build your web form with. Any control that you had with the data
grid and you delete, make it invisible instead ……..Hope this would help.
 
A

Ariel Gimenez

Thanks Felbrigg!
I dont understand what you mean with dynamic controls in the grid must be
reloaded
during postback...
Im not adding controls manually, i just using column templates, in these
columns i have changed for the edit command the textbox with a dropdowlist,
and in the item databound event im retrieving these selected values with
findcontrol and calling stored procedures in order to update the db...
First time all works fine, but in some cases (im doing a kind of validation
in the update command) i need to refire this update command and in this case
is when im getting the stinking message :(

thanks again
if u think you need more details im here to give it... just ask me
 
A

Ariel Gimenez

Thanks for your reply Mohamoss!!!
Unfortunately in my case im not deletting any control programatically, in my
previous response to Felbrigg i explained what im doing detailed.
By the way... (you are talking about hidding controls) im using one field
"id" and i dont want the user seeing it, but if i put this column
visible=false i cant retrieve the value for further use of it in the update
operation... any ideas?

Ariel Gimenez
Argentina
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top