webnoob
webnoob

Reputation: 15934

Initial SelectedValue in DropDownList not posting back when re-selected

I have a DropDownList with the following markup:

<asp:UpdatePanel id="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
    <ContentTemplate>
        <asp:DropDownList id="ddlCampaignModule" runat="server" OnSelectedIndexChanged="ddlDynamicType_SelectedIndexChanged" AutoPostBack="true">
            <asp:ListItem Value="-1">None</asp:ListItem>
            <asp:ListItem Value="10">Category Menu</asp:ListItem>
            <asp:ListItem Value="11">Best Sellers</asp:ListItem>
            <asp:ListItem Value="12">Best Reviews</asp:ListItem>
        </asp:DropDownList>
    </ContentTemplate>
</asp:UpdatePanel>

In the code behind I select the second option Category Menu. If I run my code and select any other option it posts back to ddlDynamicType_SelectedIndexChanged however if I re-select the second option (after selecting one of the other ones) my postback isn't triggered.

Am I missing something simple here?

Upvotes: 0

Views: 245

Answers (1)

MikeSmithDev
MikeSmithDev

Reputation: 15797

Sounds like you are always selecting the 2nd option in the code behind, regardless of postback... ensure you only do that if it isn't!

if (!IsPostBack)
{
    //select 2nd Item
}

Upvotes: 1

Related Questions