Report Server - unable to display correct input parameter via Iif () or Switch ()
I have a null boolean input 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 Sort parameter value
Null = "All"
True = "Sort"
False = "Unsorted"
I have also tried the following switch statement with no luck:
=Switch(Parameters!Sorted.Value="","All",Parameters!Sorted.Value="True","Sorted",Parameters!Sorted.Value="False","Unsorted")
Every time the report is displayed, I get 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
Edit # 1: per request
<ReportParameter Name="Sorted">
<DataType>Boolean</DataType>
<Nullable>true</Nullable>
<Prompt>Sorted</Prompt>
</ReportParameter>
Is this the code you requested?
a source to share
If it is a Boolean parameter, it is not semantically correct to validate as if it were a string.
You can use IsNothing(Parameters!Sorted.Value)
to test for null and then Parameters!Sorted.Value = True
(no quotes) for the second case.
I'll admit that I didn't launch Visual Studio to check if it's okay to handle boolean parameters as if they were a string, but the error you're getting sounds like it. This error is usually thrown by methods Parse
, for example if you do Int32.Parse("34.32")
, or I seem to recall. I'm guessing RS is doing automatic syntax to match data types and the equality operator can do its magic.
a source to share