![](/img/trans.png)
[英]How to refer SqlDataSource to GridView control, when SqlDataSource is created in code-behind?
[英]When does SqlDataSource populate control?
我有一个带sqldatasource
,其中填充了DropDownList
。 Webform的Page_Load
从该DropDownList
读取。
当执行Page_Load
时,似乎在DropDownList
中不存在这些值。 在Page_Load期间, DropDownList.Items.Count
等于0。
那么,何时准确填充下拉列表? 我知道我可以在sqldatasource
填充它,但是我更喜欢使用sqldatasource
。
谢谢。
这个MSDN链接帮助了我。
在Page_Load
,尚未绑定SqlDataSource
控件。 在访问控件之前,只需调用DropDownList.DataBind()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.