Adding a blank row in a combobox from a dictionary datasource

MrFantastic6
MrFantastic6 used Ask the Experts™
on
I've added a dictionary that loads as a datasource to a combobox.  I want to add a blank value so a user can essentially blank it out if the dropdown type is a dropdownlist vs a dropdown.  So to get around this, my SQL statement has a union statement in it to create this quasi blank record like "select name from table union all select '' as 'name'"

my question is, is there a better way to add a blank row into my datasource vs creating a union?  I noticed the dictionary class has a union method to it... is this the right track? I'll need an example.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Is there are reason that you are using a Dictionary over a DataTable?  In the past when I have had to implement just what you are looking to do, I use a DataTable and get the data from my database then I Insert a new row at the first position with whatever text I want (ie --Add New-- or whatever) and then check later to see the selected index = 0 for inserts.  Hopefully this helps.

Author

Commented:
I was asked to use dictionaries to load once during the formload event.  It's ultimate intent is to reduce network traffic.  I could add a function to add a blank row for each of my combos, but was hoping for something easier.

Commented:
when loading the dictionaries, just add a blank one int he first slot.

Author

Commented:
I'm doing that currently with a union all in the sql statement that creates the bindingsource.

Author

Commented:
Thanks for the help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial