Question : Operator '=' is not defined for type 'DBNull' and type 'Integer' - how to fix

I have this on my page.

<%# IIf(Eval("contactUS") = 1, "Yes", "No")%>

When I first bring up the page the value will be null.  How can I sort this out so if it's null then no.

(1 = Yes - 0 = No)

Answer : Operator '=' is not defined for type 'DBNull' and type 'Integer' - how to fix

You could fill the variable with a 0 at load just to give it _a_ value. Whenever it IS a "contactUS" the value will be overwritten anyway.

Or, not sure if this works, change the line the other way around, so in pseudo code: when not 1, "no" and else "yes".
Random Solutions  
 
programming4us programming4us