[英]Dropdown_load Event and Page_load?
I have to bind Drop down list when the Page load.In my previous Project I have used Page_Load event.Now i find an event which is Drop down_load event .I used Drop down_load and its Work well . 我必须在页面加载时绑定下拉列表。在我以前的项目中,我使用了Page_Load事件。现在我找到一个事件是Drop down_load事件。我使用了drop down_load及其工作正常。
Is there any difference between these two events,In some cases i have to bind more than 10 Drop down list. 这两个事件之间有什么区别,在某些情况下,我必须绑定10个以上的下拉列表。
so which one is best? 那么哪个最好?
eg: 例如:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //bind my Dropdown } } protected void ddlProduct_Load(object sender, EventArgs e) { if (!IsPostBack) { //bind my Dropdown } }
It depends on your requirement and when you want to bind your DropDownList
s. 这取决于您的要求以及何时绑定DropDownList
。 According to ASP.Net Page Life cycle Page_Load
event firs first and then control events, in this case the ddlProduct_Load
event. 根据ASP.Net页面生命周期,首先ddlProduct_Load
Page_Load
事件,然后ddlProduct_Load
控制事件,在本例中为ddlProduct_Load
事件。
And, this is also true according the the DropDownList
Load event's definition 并且,根据DropDownList
Load事件的定义也是如此
Fires when the page has been loaded 页面加载后触发
So, you have to make a decision where you want to bind the control. 因此,您必须决定要在哪里绑定控件。
Since you have more than 10 DropDownLists
I would suggests to use their own load event to bind your control rather than making Page_Load
looks too busy. 由于您有10个以上的DropDownLists
我建议使用它们自己的load事件绑定您的控件,而不要使Page_Load
看起来太忙。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.