Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RDLC report doesn't detect NULL values correctly

Tags:

c#

rdlc

reporting

I have a problem with generating .rdlc report. One of the columns has this expression:

IIF(CInt(Fields!MyColumn.Value) = 0 or Fields!MyColumn.Value is nothing,"Unknown",Fields!MyColumn.Value)

I've also tried to use that field as a string:

=IIF(IsNothing(Fields!MyColumn.Value) or Fields!MyColumn.Value is nothing,"Unknown",Fields!MyColumn.Value.ToString())

When the value of MyColumn is not NULL, the report displays the value properly, but when it is NULL (or 0 when it's converted into int type) the report returns #Error. The weird thing is that when I remove the if function and display only the value of that field, the report displays 0 or blank (it doesn't return the error). How can I fix this?

like image 553
NDraskovic Avatar asked Jan 11 '13 10:01

NDraskovic


1 Answers

You could try validating without a comparison:

=IIf(Fields!YourColumn.Value
    , Fields!YourColumn.Value
    , "Unknown")

Or reversing your check (check if it exists, instead of checking if it doesn't exist):

=IIf(Fields!YourColumn.Value > 0
    , Fields!YourColumn.Value
    , "Unknown")

Also, I'm not sure, but it may have something to do with using different value types in the same column. Try using the same value type for an entire column. For example, only output strings, or only output ints.

If nothing works you can also check for NULL values in your code and then set the value to 0 or -1 (or so). Then in your RDLC report you can check on that.

like image 131
Deruijter Avatar answered Oct 01 '22 18:10

Deruijter