Enable/Disable SSRS parameters

2019-09-03 19:25发布

问题:

I am pretty new to SSRS and I tried searching for the answer before posting here. I want to enable a parameter(dropdown list) when another param (also from a dropdown list) is selected. I only see a visible/hidden property on the param but nothing that would enable/disable it.

Would be great if someone could please post an example. Thanks a lot.

回答1:

In the Report Manager interface, you can't directly enable or disable a parameter with another parameter (or any code within the report.)

But you can work around this by making the options in the second parameter dynamic, based on the first parameter.

For example, in a calorie report, your first parameter might have a hard coded list of options:

First Parameter: Dessert Choice:

  • Sundae
  • Cake
  • Ice Cream Cone

A data set would use that parameter:

IF @DessertChoice = 'Sundae'
Begin
   Select 'Hot Fudge' As Subtype
   Union all
   Select 'Caramel'
END
ELSE IF @DessertChoice = 'Cake'
   BEGIN
      Select 'Chocolate' As Subtype
      Union all
      Select 'Angel Food'
   END
ELSE
   Select 'No Options' as Subtype

Use this intermediate data set as the available parameters for the second parameter.

You can also use a data set to set the default value for the second parameter, so the user does not need to select a parameter if there is only one option.

(Code above was typed into this browser without any testing, hopefully it's accurate enough for you to get the idea.)



回答2:

Cascading Parameters

http://msdn.microsoft.com/en-us/library/aa337169.aspx