reporting-servicesssrs-2008

Hide parameter (dropdown control from the toolbar) in SSRS based on another Parameter


enter image description here

I'm using .NET ReportViewer control.

We only want to display the "Dealer" dropdown if user is admin.

Is it possible to hide the "Dealer" dropdown control based on another parameter passed in, like IsAdmin?


Solution

  • The Hidden property of a parameter can only be True or False so you can't have an expression that changes the visibility dynamically.

    However, what you could do is make the @Dealer parameter's available values restrict choice based on the logged in user. For example, let's assume that each user belongs to a dealer but administrators can see all dealers. Make the SQL for the @Dealer parameter's available values be something like:

    SELECT DealerId, DealerName
    FROM Dealers
    WHERE @UserId = 'Admin'
    OR DealerId IN (SELECT DealerId FROM Users WHERE UserId = @UserId)
    

    Now the parameter will show all dealers when the user is Admin but only the specific dealer for that user when they are not. Default the parameter to the user's dealer and you are good to go.

    @UserId is a global parameter for the currently logged in user.