DBNull.Value and the dropdownlist

F

Filip De Backer

Hi everyone,

I have created a new record in a datatable, and there is an integer field
which has the value DBNull.Value, because at the moment of creation, the
application doens't know which value to use.
Then I want to bind a dropdownlist to this field of the datarow, but the
dropdownlist gives an error because it has the DBNull.Value value.
When the value of that field is set to 5 the binding is done without any
error.

The dropdownlist contains the values to store in the integer field, so the
user of the web application must choose from that drowpdownlist. There is no
default value, so I used DBNull

Is there any sollution for this problem?

thanks in advance,

Filip
 
B

Brock Allen

I'd create a second column that has an Expression property of: "IIF(Col1
is NULL, 0, Col1)" and then DataBind to the second column.
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top