Databinding ComboBox reportsto NULL problem

  • Thread starter Thread starter Diego Deberdt
  • Start date Start date
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?
 
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
 
Back
Top