Vb.net[2008] Combobox Header row when populated from datasource

R

Rob W

Greetings,

Is it possible to create a header row for a combo box which is populated
from a datasource?

For example a header row similar to '--Please choose a value--' then the
other values would be populated from the datasource.

I've looked at the combobox properties and experimented with the items.add
code statements which are rejected due to the combobox having a datasource.
I also don't have a clue how to create a pseudo row in SQL to create a
header row.

Any tips or advice would be appreciated, thanks

Rob
 
C

Cowboy \(Gregory A. Beamer\)

Often times, it is easier to adjust your data set prior to binding than it
is to add additional members to the bound control. In what you describe, you
can add it to the SQL statement or add to the data set prior to binding
(note I am saying data set and not DataSet, as your particular
implementation may be LINQ or EF).

As for creating a pseudo row in SQL, it is like this:

SELECT o as foo, 'Choose an item' as bar
UNION ALL
SELECT foo, bar
FROM Table1
Order by foo

The 0 will populate the choose at the top. You can then do whatever you need
to stop 0 from submitting, including add validation that the combo box != 0.
Hope this helps!

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

********************************************************
| Think outside the box! |
********************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top