RDLC - 使用报告服务根据条件显示数据
RDLC - Displaying data based on condition using reporting services
我正在寻找一种方法来控制地址信息在不同情况下的显示方式。
第一种情况发生在 Address1 和 Address2 字段存在时
First Name
ATT: John Doe
1000 Main Street
New York, NY 10001
地址 1 是 ATT:John Doe,地址 2 是 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
我该怎么做?
试试这个:
=IIF(IsNothing(First(Fields!Address1.Value, "MyStoredProc")),
"", First(Fields!Address1.Value, "MyStoredProc") & " - ") & First(Fields!Address2.Value, "MyStoredProc")
更新:基于用户提要的表情编辑。
我不知道你是如何安排报告中的数据的,我假设你在文本框中连接了多个字段,但我不确定。
=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 放在下一行。
让我知道这是否有帮助。
我正在寻找一种方法来控制地址信息在不同情况下的显示方式。
第一种情况发生在 Address1 和 Address2 字段存在时
First Name
ATT: John Doe
1000 Main Street
New York, NY 10001
地址 1 是 ATT:John Doe,地址 2 是 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
我该怎么做?
试试这个:
=IIF(IsNothing(First(Fields!Address1.Value, "MyStoredProc")),
"", First(Fields!Address1.Value, "MyStoredProc") & " - ") & First(Fields!Address2.Value, "MyStoredProc")
更新:基于用户提要的表情编辑。
我不知道你是如何安排报告中的数据的,我假设你在文本框中连接了多个字段,但我不确定。
=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 放在下一行。
让我知道这是否有帮助。