如何由于用户控件事件而在 ASP.Net 页面中重新绑定 GridView
我有一个带有数据网格和用户控件的网页。 用户控件有网页订阅的事件。 在用户控制事件中,我需要重新绑定网页上的数据网格。
由于附加到网格的扩展器控件表明它们在预渲染后无法注册,因此我遇到了各种各样的问题,因此看起来用户控件事件发生在页面生命周期的后期。不管怎样,这些错误都表明我完全走错了路。
如果可能的话,我不想在用户控件中引用我的页面。
实现这一目标的最佳方法是什么。
我每次都尝试在 PageLoad 上绑定网格,但发现虽然发生了数据绑定并且更新的数据位于数据源中,但网格内容并未反映这一点。 [是 GridView 视图状态在玩这个吗?]
进行完全刷新或使用页面按钮重新绑定网格允许我显示正确的值。
提前致谢,
利亚姆
I have a web page with a datagrid and a user control.
The user control has an event which the web page subscribes to.
On the user control event I need to rebind the datagrid on the web page.
I'm coming up with all sorts of problems due to extender controls that are attached to the grid indicating that they cannot be registered after prerender so it looks like the user control event occurs to late in the page life cycle. Either way those kinda errors would indicate that I'm on the wrong track completely.
I do not want a reference to my page in the user control if at all possible.
What is the best way to achieve this.
I had tried Binding the grid on PageLoad every time but found that although the Databind happened and the updated data was in the datasource that the grid contents did not reflect this. [Is it the GridView viewstate thats playing with this?]
Ding a full refresh or using a button to the page to rebind the grid allowed me to display the correct value.
Thanks in advance,
Liam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这个问题的答案(至少部分是)是第三方控件使用回调返回到服务器而不是回发,所以这可能是问题所在。了解它,网格已绑定,但未渲染。 [直到本周我才发现回调和回发之间的差异!]
不过,我愿意对此进行纠正:)
Liam 。
I think that the answer (in part at least) to this is that the third party control is using callbacks to get back to the server and not postbacks so this may be the issue. As I understand it the grid was binded OK but not rendered. [I hadn't come across the differences between Callbacks and Postbacks until this week!!]
I'm open to correction on this though. :)
Liam