Share via


Allow Null In Combo Box

Question

Thursday, March 23, 2006 5:09 PM

I have a combo box, that has its datasouce, valuemember, and display members set.  I need to allow the user to leave the null.  I need the combo box to be null when the form loads, and allow nulls if the user does not wish to select anything.  It is for a search criteria form.   Does anyone have any suggestions?

Thanks

All replies (5)

Thursday, March 23, 2006 7:07 PM ✅Answered

why not add a listitem with value "" and a space in it.

Listitem i = new ListItem;
i.Value = "";
i.Text = "";
myComboBox.Add(i);

hth,


Friday, March 24, 2006 10:06 AM ✅Answered

You can add a null value to a combobox, you have to insert a empty string instead.


Friday, March 24, 2006 8:58 PM ✅Answered

All your answers are great, but I have tried that.  The fact is that you can not add items to a combo box once its datasource property, lookupvalue, and display memeber has been set.  Maybe I will leave out the lookupvalue and displaymember, and do it the old fashion way.


Friday, March 24, 2006 12:04 PM

hi ,

just give the first value in the items list as an empty string that shud do the job


Friday, April 14, 2006 6:32 PM

I added an empty string to the list of items, then looped through my datasource adding items after the empty string.