Databinding ComboBox reportsto NULL problem

D

Diego Deberdt

I have a ComboBox (cb) that shows the Employees in the Northwind database.
The SelectedValue property of the cb is bound to the ReportsTo field of the
Employees table. One of the employees however is at the top of the pile and
does not report to anyone. For that employee, the ReportsTo field contains
NULL. The cb translates this NULL value into 0 (zero) and the first employee
in the cb is shown in this particular case. Of course, this is wrong. I want
the cb either to show an empty string or the text "None" - or whatever - in
this case.

How do I deal with this particular situation?
 
L

Lars-Erik Aabech

Hi!

There's no immediate "good" solution as far as I know, but I usually add a
row to the combobox's datasource with value 0 and text 'none'. Then if
necessary translate null to 0 in the query against the database.

HTH,
Lars-Erik
 

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