Setting SelectedIndex to 0 for DropDown with AutoPostBack set to true

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.

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

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire ASP.Net Developers

Looking to outsource your asp dot net development requirement? ASP.Net is a special feature of the DOT Net framework created by Microsoft. At [HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io"), we have a team of experienced...

Various ways of redirecting a request in Asp.Net Core

ASP.NET Core web applications often need to redirect a request to another resource based on some condition. There are multiple ways in which you can accomplish this task in ASP.NET Core MVC and Razor&#160;&#8230;

Routing in MVC - ASP.NET Core Demystified

ASP.NET Core MVC has introduced quite a few concepts that new (or new-to-ASP.NET) web developers might have some difficulty getting caught up with. My ASP.NET Core Demystified series is designed to help these developers get started building their own custom, full-fledged, working AASP.NET Core applications. In

What is the ASP.Net Machine Account on my Computer?

Some users have reported the existence of the ASP.Net machine account. In this article, I will discuss what is asp.net machine account in windows 10/7 and how to disable it, asp.net machine account password, and can I delete asp.net machine account? .NET Framework is an application on Windows that requires the installation to run several apps or games. However, when the .NET Framework is downloaded and installed, the application automatically creates an ASP NET machine account.

Add asp.net Identity in empty project

LIKE | COMMENT | SHARE | SUBSCRIBE Today, in this tutorial you will see the process of adding an ASP.NET Identity to the ASP.NET Web Application developed in...