如何正确处理复合控件中子控件的视图状态?

发布于 2024-07-06 13:52:11 字数 144 浏览 15 评论 0原文

我有一个包含 ListBox 子控件的复合控件。 回发时,列表框的项目消失。 我有一个用于初始化 ListBox 的属性,并将其添加到 CreateChildControls 中的控件集合中。 难道我做错了什么? 我是否需要做其他事情才能正确处理此列表框的视图状态?

I have a composite control that contains a ListBox child control. On postback, the items for the ListBox disappear. I have a property for the ListBox that initializes it, and I add it to the controls collection in CreateChildControls. Am I doing something wrong? Do I need to be doing something else to properly handle the viewstate of this ListBox?

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

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

发布评论

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

评论(1

独留℉清风醉 2024-07-13 13:52:11

在添加列表项或数据绑定之前,请务必将控件添加到父级。 否则,复合控件将不会跟踪列表框列表项上的视图状态。

这是更彻底的解释: http://scottonwriting.net/sowblog/posts/2129.aspx< /a>.

Be sure to add your control to the parent before you add listitems or databind. Otherwise, your composite control won't track viewstate on your ListBox's listitems.

Here's a more thorough explanation: http://scottonwriting.net/sowblog/posts/2129.aspx.

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