Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Reportviewer web control - how to reset parameters automatically after report has been run ?

$
0
0

We are using the report viewer web control on a page within our application to display a report with parameters.  Once the page is opened i can select parameters and run the report by clicking View Report, but once the report is loaded any cis I chage the parameters and click View Report nothing happens.

From what I've read i think i need to call Reset on the ReportViewer control, but i can't work out where to do this in our code.  We're showing the report in a popup window which takes the report name and userid as parameters

 protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                try
                {
                    if (Request.QueryString["r"] != null)
                    {
                        List<ReportParameter> RptParameters = new List<ReportParameter>();

                        foreach (string s in Request.QueryString.AllKeys)
                        {
                            if (s != "r" && s != "IsDlg")
                            {
                                string[] parameterValues = Request.QueryString[s].Split(',');

                                ReportParameter rp = new ReportParameter(s, parameterValues, false);
                                RptParameters.Add(rp);
                            }
                        }

                        // Set the processing mode for the ReportViewer to Remote
                        reportViewerControl.ProcessingMode = ProcessingMode.Remote;

                        ServerReport serverReport = reportViewerControl.ServerReport;
                        serverReport.ReportServerCredentials = new MyReportServerCredentials();

                        // Set the report server URL and report path
                        serverReport.ReportServerUrl =
                            new Uri(ConfigurationManager.AppSettings[AppSettingsConstants.REPORT_SERVER_PATH]);

                        string reportpath = "/";
                        string[] reportParams = Request.QueryString.GetValues("r");

                        //These paths come from the appliocation
                        if (reportParams.Length == 1)
                        {
                            reportpath += ConfigurationManager.AppSettings[AppSettingsConstants.REPORT_FOLDER];
                            reportpath += "/";
                        }

                        //These paths come from the SSRS view
                        for (int i = 0; i < reportParams.Length; i++)
                        {
                            reportpath += reportParams[i];
                            if (i < reportParams.Length - 1)
                            {
                                reportpath += "/";

                            }
                        }

                        serverReport.ReportPath = reportpath;

                        // Set the report parameters for the report
                        reportViewerControl.ServerReport.SetParameters(RptParameters);
                        // Set the timeout properties for the report
                        reportViewerControl.ServerReport.Timeout = 100000;


                    }
                }
                catch (Exception ex)
                {

                }
        }
    }


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>