Sibusiso Shongwe Sibusiso Shongwe - 5 months ago 64
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


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;