开发者

How to stop Reporting Services report from rendering automatically on startup?

I notice that if a report has default values specified to all its parameters then it renders automatically on startup. How can I prevent this? that is, I don't want the开发者_开发百科 report to be rendered until the user clicks the 'view report' button


There is no way to stop the report rendering if all parameters have default values.

The only way to stop the report rendering automatically is to have at least one parameter without a default value.


I have achieved from the below solution:

If you are using ReportViewer its posible to set the property ShowReportBody="False". Then on the OnSubmittingParameterValues event, change the ShowReportBody property to true. Then you do not need any extra parameters or parameters without default value in the report.

<rsweb:ReportViewer 
        ID="_rv" 
        runat="server"  
        Width="100%" 
        Height="100%" 
        ShowReportBody="False"
        ShowPrintButton="false"
        OnSubmittingParameterValues="rv_SubmitParamValues"/>

And then in rv_SubmitParamValuesmethod:

this.rv.ShowReportBody = true;


This is tested in SSRS2019 build 15.0.1102.962 (Apr 2022)

PROBLEM:
A report is opened, auto-fires, and renders all rows which is undesirable. Report parameters that use null are usually the culprit. In my case null is sent to a stored proc which detects that as a request to return all rows.

SOLUTION:
Auto-fire cannot be prevented but it can be short-circuited cleanly using a technique which mimics the 'select a value' option one may see in the dropdown.

AS SHOWN:

Use a Query to build Dataset 'ReportMenu' which has 3 fields         
AcctName:  Displayed in the dropdown
AcctId:    Sent to a stored proc 
SortOrder: Forces the 'Select a Client' row to the top. 

 -- Query to Build Menu Dropdown 
 -- Use any verbiage for the strings it doesn't matter
    SELECT '' as AcctID, '<Select a Client>' as AcctName, 1 as SortOrder
    UNION
    SELECT NULL, '- ALL -', 2 
    UNION 
    SELECT AcctID, AcctName, 3
    FROM   vw_Get_Active_List   -- or hardcode if preferred
    ORDER BY SortOrder, AcctName

The report auto-fires when loaded using param 'Select a Client'
Since '' isn't valid my procedure returns no rows.

The report can now be used normally. 
Users can select - ALL - to get all clients from the
dropdown or choose from the list provided by the view.

Hope this helps !

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜