Set DropDownList to nothing (blank)

G

Greg

I'm trying to set a asp:DropDownList control value to blank/null for records
that have no value. But, I'm finding that even though their is no value in my
source data, it displays a record from the drop down list anyways. How can I
have the DropDownList showing nothing when no value exists?

this.lstManagerID.Text = string.empty;
this.lstManagerID.SelectItemValue = string.empty;
this.ManagerID.SelectedItem.Value = string.Empty;

None of these options set the DropDownList to show nothing.

Any suggestions?

Thx
 
N

Nathan Sokalski

Try this:

this.lstManagerID.Items.Clear();

There is also a Remove() method, but that is obviously only used for
removing one ListItem at a time. The code that you included in your posting
simply changes the Text or Value property of the currently selected
ListItem, but the ListItem still exists in the DropDownList. Good Luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top