vb.net - Conditional statement in databound expression -


i want display image if 2 conditions met.

  1. the data item not null
  2. 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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -