用户控件和视图状态

发布于 2024-08-25 00:30:55 字数 212 浏览 5 评论 0原文

我有一个用户控件,在其中显示 telerik radgrid 和一些文本框和 radcombo 框。我的 radcombo 框在回发时丢失视图状态。文本框和网格保持其状态,但组合框则不然。有什么线索吗?我在某处读到,用户控件上的数据绑定控件在回发时不会维护其状态。这看起来很卢达克里斯,此外,我的数据绑定 radgrid 不会“丢失”它的数据。

有什么想法吗?提前致谢。

史蒂夫

I have a user control where I display a telerik radgrid and some textboxes and radcombo boxes. My radcombo boxes lose view state on postbacks. The text boxes and the grid maintain their state, but not the combo boxes. Any clues why? I read somewhere that databound controls on user controls don't maintan their state on postbacks. This seems ludacris and besides, my databound radgrid doesn't "lose" it's data.

Any ideas? Thanks in advance.

Steve

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩发小公举 2024-09-01 00:30:55

您是动态(在代码隐藏中)还是静态(aspx 标记)添加这些用户控件?

如果您动态创建它们,请确保在每次回发时重新创建它们,并确保不晚于 OnInit() 发生。这样可以恢复视图状态。

Are you adding these user controls dynamically (in code-behind) or statically (aspx markup)?

If you are creating them dynamically, make sure they are recreated on every postback, and make sure that is occurs no later than OnInit(). This way the viewstate can be restored.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文