且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从动态生成文本框​​输入值

更新时间:2023-09-29 18:29:52

您需要移动 BindDropDownLists(); 从Page_Load中的Page_Init方法或其他页面的生命周期会找不到视图状态并连接到您的控件。通过你在Page_Load中的时候,你都来不及。确保您的逻辑来创建初始化中的控制和你的逻辑来检索加载/事件中的数据,你应该看到一些成果。

You need to move BindDropDownLists(); to the Page_Init method from Page_Load or else the page lifecycle will not find the viewstate and attach to your controls. By the time you are in Page_Load you are too late. Make sure your logic to create the controls in init and your logic to retrieve the data in load/events and you should see some results.

您不需要视图状态的东西,会自动将自身线了,你不能像点击控制事件创建动态控制或作为的SelectedIndexChanged在生命周期为时已晚,多数民众赞成。动态控件需要加载之前要创建的视图状态来的时候负载接线恶有恶报。

You don't need the viewstate stuff as that will automagically wire itself up, you can't create the dynamic controls in a control event like click or selectedindexchanged as thats too late in the lifecycle. The dynamic controls need to be created before load for the viewstate to be wired by the time load comes around.

更多的阅读