简体   繁体   中英

Dropdown “OnSelectedIndexChanged” Event Not Firing

I have a dropdown as

<asp:DropDownList ID="ddl" runat="server" AutoPostBack="true" DataTextField="Month Name" DataValueField="Year"  OnSelectedIndexChanged="ddl_SelectedIndexChanged" ></asp:DropDownList>

For my dropdown binding I'm retrieving data form dataset and filtering data based on some condition as shown below. Then converting to datatable and binding to dropdown

Binding :

        DataRow[] rows = ds.Tables[0].Select("Year = '2015'");
        DataTable dt = rows.CopyToDataTable();
        ddl.DataSource = dt;
        ddl.DataBind();

Binding is happening nicely but my OnSelectedIndexChanged event not firing. I found out that is due to the binding, whats wrong am I doing

protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{

}

您还应该添加属性ViewStateMode="Enabled"EnableViewState="true"

请使用Autopostback属性AutoPostBack =“ true”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM