How can I trap “View Report” in ReportViewer (webforms) for SSRS?

≡放荡痞女 提交于 2019-12-08 05:47:29

问题


I am using ReportViewer.WebForms in asp.net page. I have the parameter toolbar showing up where I can select a parameter, it does a postback to get the next parameter (dependent on the first), and so forth.

When I click the View Report button there is a postback and the report will display fine.

All this works great.

What I would like to do is set the ShowReportBody to false

ReportViewer.ShowReportBody = False

At this point I would like to grab all the parameters that have been selected by the user and run the render method to export to a file (of my choosing .. maybe excel, maybe pdf .. does not really matter, nor is the topic of this question).

So, my question is, how (or can I) trap the button event of the View Report button? I would like to be able to use the ReportViewer UI in order to capture all the parameters instead of building custom parameters.

I'd also like to rename this, but, again .. another topic :)


回答1:


You can use the IsPostBack flag and QueryString

Example:

Viewer.ShowReportBody = false

if(IsPostBack)
{
    if(Request.QueryString["Exec"] = "Auto")
        Viewer.ShowReportBody = true;
    ...
}
else
{
    Viewer.ShowReportBody = true;
}


来源:https://stackoverflow.com/questions/1573926/how-can-i-trap-view-report-in-reportviewer-webforms-for-ssrs

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