对回发进行持久动态控制
我有一个在 page_load 上加载的数据网格。
在这种情况下,我无法在 page_init 中加载数据网格,因为数据网格的结果由复选框确定,并且由于未加载视图状态,该复选框在 page_init 期间始终设置为 true。
我在数据网格上有一个 OnItemDataBound 事件,它动态创建控件,后来我想访问其中一些控件的值(例如文本框)
当然问题是我无法访问这些控件值,因为它们不坚持回发。知道如何解决这个问题吗?
I have a datagrid that loads on page_load.
In this instance I can't load the datagrid in page_init as the results of the datagrid are determined by a checkbox and the checkbox would always be set to true during page_init thanks to the viewstate not being loaded.
I have an OnItemDataBound event on the datagrid that dynamically creates controls and later on I want to access the value of some of these controls (e.g. a text box)
Of course the problem is I can't access these controls values as they don't persist over a postback. Any idea how I can get round this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将代码放入 Page_Init 中,然后使用 Request.Form 集合检查复选框的值以查看是否发生任何更改。这是一种方式,如下所示:
You could put the code in Page_Init, and then check the value for the checkbox using the Request.Form collection to see if any change happened. That would be one way as in: