We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Adding blank to databound combobox

I have a combo box which is databound to a SQL database. The database table does not include a "null" or "blank" entry. I would like the user to be able to select a blank to clear the current data which is set. Currently, if there is no data and the user does not change the combo box, it works fine, however if they change the selection in the combobox, the blank disappears. I tried changing the SelectedItem property to -1 and to Nothing, but it still shows the first item in the list. Thanks

1 Reply

MI mike September 3, 2003 01:54 PM UTC

set the data source query for your combobox to include a union clause with a null or blank value. eg. my combobox datasource SELECT Data FROM Table UNION ALL (SELECT '') ORDER BY 1; this should put the blank option as the first entry in the combobox list. hope this helps > I have a combo box which is databound to a SQL database. The database table does not include a "null" or "blank" entry. I would like the user to be able to select a blank to clear the current data which is set. > > Currently, if there is no data and the user does not change the combo box, it works fine, however if they change the selection in the combobox, the blank disappears. > > I tried changing the SelectedItem property to -1 and to Nothing, but it still shows the first item in the list. > > Thanks >

Loader.
Live Chat Icon For mobile
Up arrow icon