WEFX
WEFX

Reputation: 8552

Why isn't selectedindexchanged firing?

I have the following DropDownList defined:

<asp:DropDownList ID="ddlStuff" CssClass="myCssClass" OnSelectedIndexChanged="PopulateAnotherDropdown" runat="server"></asp:DropDownList>

However, my PopulateAnotherDropdown method isn't firing. I have a breakpoint set on the method, and it's not being hit.

Here is my method write-up in code-behind:

public void PopulateAnotherDropdown(object sender, EventArgs e)
{
    ...
}

For what it's worth, the page is rendering as follows:

<select name="ctl00$MainContent$ddlStuff" id="MainContent_ddlStuff" class="myCssClass">

Any ideas?

Upvotes: 1

Views: 187

Answers (2)

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

Because you forget to add: AutoPostBack="true"

To fire the SelectedIndex of the dropdownlist control, it needs to postback to the server. For that to happen you to have to set AutoPostBack="true" in the control property.

Upvotes: 6

SMK
SMK

Reputation: 2158

Please Set

AutoPostBack="true"

of the dropdown.Because by default it is false except button control

Upvotes: 2

Related Questions