RDLC - 使用报告服务根据条件显示数据

时间:2015-10-19 21:07:06

标签: reporting-services rdlc

我正在寻找控制地址信息在不同情况下的显示方式。

当Address1和Address2字段存在时,第一种情况发生

First Name
ATT: John Doe
1000 Main Street
New York, NY 10001

其中Address1是ATT:John Doe和Address2是1000 Main Street

当Address1不存在时发生第二种情况:

First Name
1000 Main Street
New York, NY 10001

其中Address2是1000 Main Street

我在报告中定义了以下逻辑:

=IIF(IsNothing(First(Fields!Address1.Value, "MyStoredProc")),"",First(Fields!Address2.Value,"MyStoredProc"))

该逻辑显示以下内容:

First Name
1000 Main Street
New York, NY 10001

但是,它应该显示:

First Name
ATT: John Doe
1000 Main Street
New York, NY 10001

因为,数据库中存在Address1数据。

所以,基本上,我只想在它存在的情况下显示Address1。

或换句话说,

当Address1存在时,我需要显示以下内容:

First Name
ATT: John Doe
1000 Main Street
New York, NY 10001

当Address1不存在时,我需要显示以下内容:

First Name
1000 Main Street
New York, NY 10001

我该怎么做?

1 个答案:

答案 0 :(得分:1)

试试这个:

=IIF(IsNothing(First(Fields!Address1.Value, "MyStoredProc")),
 "", First(Fields!Address1.Value, "MyStoredProc") & " - ") & First(Fields!Address2.Value, "MyStoredProc")

更新:基于用户Feed的表达式版本。

我不知道你在报告中如何安排数据我假设你在文本框中连接多个字段但我不确定。

=IIF(IsNothing(First(Fields!Address1.Value, "MyStoredProc")) or
First(Fields!Address1.Value, "MyStoredProc") = "",
"", First(Fields!Address1.Value, "MyStoredProc") & VbCrLf) & First(Fields!Address2.Value, "MyStoredProc")

我已经为空字符串字段("")添加了验证。另外,我添加了一个换行符VbCrLf,如果地址1存在,则将第二个地址2放在下一行。

如果这有用,请告诉我。

相关问题