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.
Unfortunately, activation email could not send to your email. Please try again.

Adding blank to databound combobox

Thread ID:

Created:

Updated:

Platform:

Replies:

6321 Aug 8,2003 09:21 AM Sep 3,2003 09:54 AM Windows Forms 1
loading
Tags: FAQ
Dawn Nedohin-Macek
Asked On August 8, 2003 09:21 AM

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

mike
Replied On September 3, 2003 09:54 AM

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 >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;