Setting SelectedIndex to 0 for DropDown with AutoPostBack set to true

I am using a DropDown button with AutoPostBack set to true. I'm trying to reset the DropDown to the default selection on page postback -- DropDown.SelectedIndex = 0;. The DropDown does reset to the default selection but I'm unable to make a selection as it continuously reverts to the default position "Make a Selection" immediately after selecting another option. I'm not sure if it matters but this is placed inside an update panel.

One of the reasons I need this to set back to 0 is that when I click the back button on the browser, the last selection is selected and if the user tries to go back to the same selection, that particular selection in the DropDown doesn't work unless I refresh the page. For example. Choice 1 redirects me to page2. If I click back, Choice 1 is still selected. If I click the drop down to select Choice 1 again, nothing happens unless I refresh the page. Here is my DropDown HTML:

<asp:DropDownList ID="DropDown" runat="server" EnableViewState="true" 
AppendDataBoundItems="true" AutoPostBack="true" 
OnSelectedIndexChanged="DropDown_SelectedIndexChanged">
                    <asp:ListItem>Make a Selection</asp:ListItem>
                    <asp:ListItem>Choice 1</asp:ListItem>
                    <asp:ListItem>Choice 2</asp:ListItem>
                </asp:DropDownList>

And C#:

if (IsPostBack)
        {                
            DropDown.SelectedIndex = 0;
    }


#c-sharp #asp.net

1 Likes8.75 GEEK