Sibusiso Shongwe Sibusiso Shongwe - 1 year ago 106
ASP.NET (C#) Question

How to Remove the SelectedIndex of a DropDownList?

I have an ASP.NET Web Forms that inserts values into a database, I want to reset the selected items in the

, how do I do it properly?? I know with
I can use
TextBox1.Text = String.empty
but it doesn't seem to work with the

Answer Source

For DropDownList it would be better to first add an empty string at first position of the DropDownList by using yourDropDownList.Items.Insert method and then select it. Something like this:

yourDropDownList.Items.Insert(0, new ListItem(string.Empty, string.Empty));
yourDropDownList.SelectedIndex = 0;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download