Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

This doesn't 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? Doesn't 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

  • 4 weeks later...
Guest MichaelK
Posted

I've found that the -1 SelectedIndex only works for a DropDownStyle of 'DropDown', not 'DropDownList'.

 

You didn't mention specifically what your DropDownStyle is, but this is a simple check...

 

MichaelK

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...