Can't get selectedindex = -1 to work

jhilb

Active member
Joined
Jan 14, 2002
Messages
27
This doesnt seem to work for me. The binding works, but the clearing of the selected item does not. After binding, I want to set the selectedindex to -1 which should no "no selection" right? Doesnt work. Always selects the first item.


Clear and bind the events dropdown
ddEvents.DataSource = Nothing
ddEvents.Items.Clear()
ddEvents.DataSource = oDB.GetDataView("SELECT * FROM tbEvent where evtcustomerid = " + CompanyId + " and evtIsDeleted = 0")
ddEvents.DataTextField = "evtName"
ddEvents.DataValueField = "evtEventId"
ddEvents.DataBind()
ddEvents.SelectedIndex = -1
 
Ive found that the -1 SelectedIndex only works for a DropDownStyle of DropDown, not DropDownList.

You didnt mention specifically what your DropDownStyle is, but this is a simple check...

MichaelK
 
Back
Top