473,378 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Set DropDownList to nothing (blank)

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
Oct 3 '08 #1
1 4790
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!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Greg" <Ac**********@newsgroups.nospamwrote in message
news:A9**********************************@microsof t.com...
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

Oct 3 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mike D | last post by:
I've databound the dropdownlist. How do I prevent it from selecting the first item in the list during page load.
3
by: Northern | last post by:
I need to write code clear the display box of my DropDownList (something like clear current selected item) while still keep the loaded item list in the DropDownList. I tried DropDownList's...
1
by: Mark | last post by:
I'm using dropdownlist in a datagrid to allow a column in a table to be edited. The dropdownlist contains several the from "dictionary/ code-decode" table. These columns are NOT required in the...
2
by: Shiju Poyilil | last post by:
Hello, I have a datagrid with only one row and its having 2 dropdownlists, I need to populate the secodn dropdownlist on the basis of the selection in the first dropdown. but I am not able to...
0
by: Mark Rae | last post by:
Hi, Trying to debug an ASP.NET v1.1 site where ToolTips are not displaying on <asp:DropDownList> controls. Since this isn't a built-in property of these controls, I did a Google search and the...
2
by: MrSmoofy | last post by:
Ok I'll start out with I found: http://support.microsoft.com/kb/327244/ BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1 Ok so in HTML you can have: <select id="MyList">...
5
by: Øyvind Isaksen | last post by:
When I bind the dropdownlist-control to a datareader, it displays all the data (from the database) in the dropdownlist. My question is: How do I insert a "<option value="">Choose...</option>" in...
4
by: Sevu | last post by:
I am working with ASP.NET.I am using ReportViwer Control to show my report.I like to add dropdownlist with in the reportviewer control. ( Not top to the control some thing like that).I need to...
5
by: Victorious1 | last post by:
Why doesn't the the SelectedIndexchanged event for my dropdownlist ever get executed? Why do I get a page not found error when I select a new item? My dropdownlist is within a form. The items...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.