1. To enable automatic submission of DropDownList, you must set the AutoPostBack = "true" attribute. The following code is used:
Copy codeThe Code is as follows:
<Asp: DropDownList ID = "ddlNameList" runat = "Server" Height = "30"
AutoPostBack = "True" onselectedindexchanged = "ddlNameList_SelectedIndexChanged"> </asp: DropDownList>
2. During Processing on the server, especially during initialization of DropDownList, the error code is as follows:
Copy codeThe Code is as follows:
Protected void Page_Load (object sender, EventArgs e)
{
If (! Page. IsCallBack)
{
This. fillIntoNameList ();
}
}
This initialization error occurs and will be initialized every time it is uploaded to the server. This results in that each time the SelectIndex of DropDownList is obtained, it can only be 0.
The correct code is as follows:
Copy codeThe Code is as follows:
Protected void Page_Load (object sender, EventArgs e)
{
If (! Page. IsPostBack)
{
This. fillIntoNameList ();
}
}