Gridview不保持回发状态 [英] Gridview is not maintaining state on postback
问题描述
我遇到的情况是我正在使用2个gridview,每个都有一个复选框来选择该行,现在在第一个gridview上选中一个复选框时,该行将添加到第二个gridview上.
我正在通过选择第一个gridview的复选框和.cs类上的__dopostback
来执行此操作,我正在第二个gridview上添加该行.
问题:
1)回发后在第一个gridview上未选中该复选框,gridview不会保持状态吗?
2)在第二回发时,我无法获取第二gridview的数据源.
请指教.
谢谢.
Divya
Hi,
I have a situation where I am using 2 gridviews each having checkbox to select the row, Now on the selection of a checkbox on first gridview that row gets added on 2nd gridview.
I am doing it by __dopostback
on the selection of the checkbox of first gridview and on .cs class I am adding that row on 2nd gridview.
Issues:
1) the check box is not checked on first gridview after postback, Does gridview not maintain a state?
2) on second post back I am not able to get the datasource of second gridview.
Please advise.
Thanks.
Divya
推荐答案
基于您所说的,我只能说检查您在哪里创建gridview ...在aspx页面中,或在代码背后创建?如果在代码后面,请在Page_Init()方法中创建它,以帮助在回发期间将其持久化.
Only thing I can say based on what you''ve said, is check where you are creating the gridview... is it in the aspx page, or created in the code-behind? If code-behind, create it in the Page_Init() method to help persist it during postbacks.
这篇关于Gridview不保持回发状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!