I have a nullable boolean input parameter with the following expression in my textbox:
我有一个可以为空的布尔输入参数,在我的文本框中有以下表达式:
=iif(Parameters!Sorted.Value="","All",iif(Parameters!Sorted.Value="True","Sorted","Unsorted"))
and I am trying to display this based on the value of Sorted input parameter
我试图根据Sorted输入参数的值显示这个
Null = "All"
Null =“全部”
True = "Sorted"
True =“已排序”
False = "Unsorted"
错误=“未分类”
I have also tried the following switch statement without any luck:
我也试过以下开关语句没有任何运气:
=Switch(Parameters!Sorted.Value="","All",Parameters!Sorted.Value="True","Sorted",Parameters!Sorted.Value="False","Unsorted")
Each time when the report renders I receive the following error:
每次报表呈现时,我都会收到以下错误:
The value expression for the textbox ‘textbox7’ contains an error: Input string was not in a correct format.
I am using VS2003 and SSR Designer v 8.0
我使用的是VS2003和SSR Designer v 8.0
Edit #1: Per request
编辑#1:每个请求
<ReportParameter Name="Sorted">
<DataType>Boolean</DataType>
<Nullable>true</Nullable>
<Prompt>Sorted</Prompt>
</ReportParameter>
Is this the code you were requesting?
这是您要求的代码吗?
3 个解决方案
#1
Okay, I think your problem may be that your DataType is Boolean, and you are specifying a blank value. You cannot do that.
好的,我认为您的问题可能是您的DataType是布尔值,并且您指定了一个空值。你不能这样做。
Instead, try to specify the keyword Nothing:
相反,尝试指定关键字Nothing:
=iif(Parameters!Sorted.Value=nothing,"All",iif(Parameters!Sorted.Value="True","Sorted","Unsorted"))
#2
If it is a Boolean type parameter it's not semantically correct to check it as if it were a string.
如果它是一个布尔类型参数,那么检查它就好像它是一个字符串一样。
You can use IsNothing(Parameters!Sorted.Value)
to check for a null and then Parameters!Sorted.Value = True
(without the quotes) for the second case.
您可以使用IsNothing(Parameters!Sorted.Value)检查null,然后使用Parameters!Sorted.Value = True(不带引号)来表示第二种情况。
I'll admit I didn't fire up Visual Studio to check if it normally is okay with treating Boolean parameters as if they were a string, but the error you're getting sounds as such. That error is usually thrown by Parse
methods, like if you do Int32.Parse("34.32")
, or so I seem to recall. I'm guessing RS is doing an automatic parse so that the datatypes match and the equality operator can do its magic.
我承认我没有启动Visual Studio来检查它是否正常,将布尔参数视为字符串,但是你得到的错误就是这样。这个错误通常是由Parse方法抛出的,比如你做Int32.Parse(“34.32”),或者我似乎记得。我猜测RS正在进行自动解析,以便数据类型匹配,并且相等运算符可以发挥其魔力。
#3
Why not change the logic to test explicitly for True or False and then drop through to "All"? And without worrying about string, True vs "true" etc
为什么不将逻辑更改为显式测试True或False,然后切换到“All”?并且不用担心字符串,True与“true”等
=iif(Parameters!Sorted.Value,"Sorted",iif(NOT(Parameters!Sorted.Value), "Unsorted","All"))
(Can't test and hope NOT is correct :-)
(不能测试,希望不是正确的:-)
#1
Okay, I think your problem may be that your DataType is Boolean, and you are specifying a blank value. You cannot do that.
好的,我认为您的问题可能是您的DataType是布尔值,并且您指定了一个空值。你不能这样做。
Instead, try to specify the keyword Nothing:
相反,尝试指定关键字Nothing:
=iif(Parameters!Sorted.Value=nothing,"All",iif(Parameters!Sorted.Value="True","Sorted","Unsorted"))
#2
If it is a Boolean type parameter it's not semantically correct to check it as if it were a string.
如果它是一个布尔类型参数,那么检查它就好像它是一个字符串一样。
You can use IsNothing(Parameters!Sorted.Value)
to check for a null and then Parameters!Sorted.Value = True
(without the quotes) for the second case.
您可以使用IsNothing(Parameters!Sorted.Value)检查null,然后使用Parameters!Sorted.Value = True(不带引号)来表示第二种情况。
I'll admit I didn't fire up Visual Studio to check if it normally is okay with treating Boolean parameters as if they were a string, but the error you're getting sounds as such. That error is usually thrown by Parse
methods, like if you do Int32.Parse("34.32")
, or so I seem to recall. I'm guessing RS is doing an automatic parse so that the datatypes match and the equality operator can do its magic.
我承认我没有启动Visual Studio来检查它是否正常,将布尔参数视为字符串,但是你得到的错误就是这样。这个错误通常是由Parse方法抛出的,比如你做Int32.Parse(“34.32”),或者我似乎记得。我猜测RS正在进行自动解析,以便数据类型匹配,并且相等运算符可以发挥其魔力。
#3
Why not change the logic to test explicitly for True or False and then drop through to "All"? And without worrying about string, True vs "true" etc
为什么不将逻辑更改为显式测试True或False,然后切换到“All”?并且不用担心字符串,True与“true”等
=iif(Parameters!Sorted.Value,"Sorted",iif(NOT(Parameters!Sorted.Value), "Unsorted","All"))
(Can't test and hope NOT is correct :-)
(不能测试,希望不是正确的:-)