I have a DDL within an update panel and I cannot get the SelectedItemChanged method to fire when I bind data to it. In Page_Load I have:
ddl.DataSource = GetList();
ddl.DataBind();
GetList() returns a List<string>
The values are all there but nothing happens when I select one.
If I am to manually put them in like so:
ddl.Items.Add("1");
ddl.Items.Add("2");
ddl.Items.Add("3");
it works, why?
The method below is never entered into if I bind the data.
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
string test = ddl.SelectedItem.Text;
}
<asp:DropDownList runat="server" ID="ddl" Width="150px"
OnSelectedIndexChanged="ddl_SelectedIndexChanged"></asp:DropDownList>
By default the Change asp:DropDownList does not do postback like button as that is not required in many cases. You have to set it to true to get the postback.
Change
To