Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I add a blank value selection to my array? (vb) 1

Status
Not open for further replies.

Rexxx

MIS
Oct 16, 2001
47
0
0
I have the following array (see below) and it populates a dropdownlist. The way it works now is without an initial selection the dropdownlist displays a blank ("") value. Once the user makes a selection from the dropdownlist and updates accordingly then wishes to go back and clear the selection by selecting a blank in the dropdownlist no blank is provided as an option to select. How can I add a blank to this array?

Dim selectCMD7 As SqlCommand = New SqlCommand()
Dim data7 as SqlDataReader
selectCMD7.CommandText = "Select coname From org where orgtype = 'Fund'"
selectCMD7.Connection = dbconn1
selectCMD7.CommandTimeout = 30
dbconn1.Open()
data7 = selectCMD7.ExecuteReader()
Dim fund1array as ArrayList
fund1array = new ArrayList()
fund1array.add("")
Do while data7.read()
fund1array.add(data7("coname"))
loop
dbconn1.close()
fund1array.Insert(0, coDS.tables("company").Rows(0).Item("fund"))
fund1.DataSource = fund1array
fund1.DataBind()
 
Not sure why your blank isn't showing up but you could try a couple of things.
1. Add a blank to the drop down rather than the list.
fund1.Items.Insert(0, "")

2. Insert a blank at the top of the array
fund1array.Insert(0, "")

3. The blank that you see at the begining is because the dropdown selected index is set to -1. So add a button that clears your controls and sets the index to -1
'clear stuff here
fund1.SelectedIndex = -1


Hope that solves it. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top