无法加载ViewState异常 [英] Failed to Load ViewState Exception

查看:122
本文介绍了无法加载ViewState异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在获取此异常,我不知道我在哪里做错了
实际上,我有一个gridview,在页脚中有一个下拉文本框和一个按钮单击按钮,当我单击按钮两次时,我在列表中两次添加了dropdownselected值和文本框文本,但是当我第三次单击时,我开始收到此异常/>
无法加载viewstate.加载视图状态的控制树必须与在上一个请求期间用于保存视图状态的控制树匹配.例如,当动态添加控件时,在回发期间添加的控件必须与在初始请求期间添加的控件的类型和位置相匹配

如果我关闭了启用视图状态,则在mygrid中仅填充一次... ...

i m getting this exception i dont where have i done mistake
actualy i have a gridview, in footer i have dropdown textbox and a button on button click i m adding the dropdownselected value and textbox text in list two times when i click on button it works but when i click third time i start getting this 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

if i turn off the enable viewstate then in mygrid only one time items are populated ...

推荐答案

您是否动态添加任何控件(即在运行时的代码中)?如果是这样,则必须在加载ViewState之前以相同的方式添加控件,最好在页面初始化时执行此操作.

请参阅 [
Do you add any controls dynamically (ie in code at runtime)? If so you must add the controls in the same way before the ViewState is loaded, it is best to do this when the page initialises.

See this[^] MSDN article for more guidance.


这篇关于无法加载ViewState异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆