My code:
*.aspx:
<asp:DropDownList ID="CountryList" CssClass="CountryList" runat="server"
OnSelectedIndexChanged="CountryList_SelectedIndexChanged" />
*.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
CountryList.SelectedIndexChanged +=
new EventHandler(CountryList_SelectedIndexChanged);
...
}
protected void CountryList_SelectedIndexChanged(object sender, EventArgs e)
{
LoadCityList(CountryList, CityList);
}
But this doesn't work.
Try setting
AutoPostBack="true"
on this dropdown list:Also you don't need to manually wire-up the event handler in the
Page_Load
method. It will be automatically done by ASP.NET when it compiles the webform:Add AutoPostBack="true" in ur aspx code and everything will work as you thought.
I think you missed AutoPostBack="true" Property in aspx file