Hide parameter (dropdown control from the toolbar)

2019-09-18 10:31发布

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?

1条回答
相关推荐>>
2楼-- · 2019-09-18 10:41

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.

查看更多
登录 后发表回答