vb.net - Conditional statement in databound expression -
i want display image if 2 conditions met.
- the data item not null
- the value of data item greater 0
markup
<img id="img1" runat="server" visible='<%#iif( databinder.eval(container.dataitem, "amount") dbnull.value or databinder.eval(container.dataitem, "amount") = 0, false, true)%>' src="/images/check.png" />
error message
operator '=' not defined type 'dbnull' , type 'integer'. description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.
exception details: system.invalidcastexception: operator '=' not defined type 'dbnull' , type 'integer'.
try using orelse
. in vb.net or
conditional operator causes both sides evaluate regardless of success. if have null it's going attempt comparison anyway. using orelse
cause second condition not evaluated if first true.
Comments
Post a Comment