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

自古美人都是妖i 提交于 2020-02-08 01:29:09

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/21481738/hide-parameter-dropdown-control-from-the-toolbar-in-ssrs-based-on-another-para

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!