在Rdlc报表中检查Null值 [英] check Null value in Rdlc Report
本文介绍了在Rdlc报表中检查Null值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查文本框字段中的Null值,如果它为Null,则打印一些内容.我尝试了Is Nothing但仍显示#ERROR.
= IIF(Fields!NonTechHours.Value is Nothing,"Null",IIF(Right(Fields!NonTechHours.Value,InStr(Fields!NonTechHours.Value,."))> 0,Fields!NonTechHours.Value,Left( Fields!NonTechHours.Value,InStr(Fields!NonTechHours.Value,.")-1))))
Hi,
I want to check Null value in textbox field,if it ''s Null,then print something.I tried Is Nothing but still getting the #ERROR display.
=IIF(Fields!NonTechHours.Value is Nothing,"Null",IIF(Right(Fields!NonTechHours.Value,InStr(Fields!NonTechHours.Value,"."))>0,Fields!NonTechHours.Value,Left(Fields!NonTechHours.Value,InStr(Fields!NonTechHours.Value,".")-1)))
推荐答案
如果您使用的是.Net 2.0或更高版本,您实际上可以使用null合并运算符-??.
这将自动将null转换为".
您的代码将类似于Fields!NonTechHours.Value?? ""
.
If you are using .Net 2.0 or above, you can actually use the null coalesce operator - ??.
This will convert null into "" automatically.
Your code will be something likeFields!NonTechHours.Value?? ""
.
textbox类的text属性是一个字符串.它甚至不会接受System.DBNull.Value作为值.如果将其设置为与其他对象相等,则将其转换为字符串.
基于此,TextBox1.Text = ""
和其他任何东西一样可行.
The text property of the textbox class is a string. It wont even accept System.DBNull.Value as a value. If you set it equal to some other object, it will be cast as string.
Based on this,TextBox1.Text = ""
is just as viable as anything else.
这篇关于在Rdlc报表中检查Null值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文