Home All Groups Group Topic Archive Search About

DBNull.Value and the dropdownlist

Author
15 Apr 2005 10:40 AM
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

Author
15 Apr 2005 3:09 PM
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.

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> 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
>