Let's take a look at the questions of netizens:
According to the Asp. NET mechanism, the DropDownList write control in html markup is a little different from the Dynamically Loaded control. If you write the DropDownList control in html markup, that is, the. aspx webpage, the user code is correct. However, if the control is dynamically loaded in. aspx. cs, it cannot be loaded in the Page_Load event. If it is loaded as this, it will not work even if AutoPostBack = true.
The correct method isLoad in the Page_Init event.
In the following dynamic real-time operations, the first step is to run the code of netizens, and it is determined that the Code cannot be run. Then Insus. NET writes the Page_Load event and the Showpage method Comment out, and copies the dynamically generated DropDownList control to the page_Init event. The last miracle happened, and it was able to run correctly.
Code in the demo:
Page_Init (= ListItem (, + = Page_Load (ddl_SelectedIndexChanged (= + dl. SelectedValue + View Code