I'd like to know what the best method is for handling NULL
(or 0)
values within a DropDownList.
If a database lookup value is optional I would normally
consider
leaving it NULL but this leads to problems with DopDownLists
because
there is no value to bind to.
I considered a method whereby the DropDownList has a an
index value of
0 inserted with a space character as the text. As it has a 0
index
value it would appear at the top of the list and would
indicate that no
selection had been made. Within the database the column
would be
defined with a default value of 0. Thus the 0 value
retrieved from the
db would bind to the 0 value inserted into the DropDownList.
I've tried to get this approach to work but the code always
errors
because there is no value to bind the retrieved db value
against. I've
obviously not got the o value insertion in the right place.
The web form is filling a formview control via a
sqldatasource
following the selection of a record on a gridview.
Can someone point me in the right direction as to how such
optional
lookup data in a dropdownlist should be handled
|