RDLC 报告未正确检测 NULL 值 [英] RDLC report doesn't detect NULL values correctly

查看:47
本文介绍了RDLC 报告未正确检测 NULL 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在生成 .rdlc 报告时遇到问题.其中一列具有以下表达式:

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())

当MyColumn的值不为NULL时,报表正常显示,但当为NULL(或转为int类型时为0)时报表返回 #Error.奇怪的是,当我删除 if 函数并仅显示该字段的值时,报告显示 0 或空白(它不返回错误).我该如何解决这个问题?

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?

推荐答案

您可以尝试在不进行比较的情况下进行验证:

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.

如果没有任何效果,您还可以检查代码中的 NULL 值,然后将该值设置为 0 或 -1(左右).然后在您的 RDLC 报告中,您可以进行检查.

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.

这篇关于RDLC 报告未正确检测 NULL 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆