1

i want to set visibility on or off on PendingApproval value but in database PendingApprovalfield is allow null true so I got error here is code

I got this error Conversion from type 'DBNull' to type 'Integer' is not valid.

 style="margin-left:6px; margin-top:auto; display:<%#  IIf(CTYPE(Eval("PendingApproval"),Integer) = 1, "block", "none")%>"
Andy
  • 95
  • 1
  • 3
  • 14
  • 1
    Solution here: http://stackoverflow.com/questions/1979806/using-evalitem-handling-null-value-and-showing-0-against – tezzo Jun 27 '13 at 06:54

2 Answers2

1

Try this. I am assuming if the value is NULL then visibility need to set off

style="margin-left:6px; margin-top:auto; display:<%# IIf(Eval("PendingApproval")=DBNull.value,"none", IIf(Eval("PendingApproval") = 1, "block", "none"))%>"

A suggestion, in the query used to pull the report can you apply ISNULL() function like below:

SELECT col1, ISNULL(PendingApproval,0), ..., coln FROM TABLE1

By this way you will get value 0 for NULL and your old code will work well without comparing for DBNull.value

SMS
  • 452
  • 2
  • 6
  • I use this but got error BC30452: Operator '=' is not defined for types 'Object' and 'System.DBNull'. also use == but its also not works – Andy Jun 27 '13 at 07:07
0

To prevent that error you try this ..

style="margin-left:6px; margin-top:auto; display:<%#Iif(Eval("PendingApproval") Is Null,"none",IIf(CTYPE(Eval("PendingApproval"),Integer) = 1, "block", "none"))%>"
matzone
  • 5,703
  • 3
  • 17
  • 20