Quantcast
Channel: SQL Server Reporting Services
Viewing all articles
Browse latest Browse all 1418

ssrs hidden parameter added from asp.net report viewer control

$
0
0

I am using asp.net report viewer control in a 2012 asp.net web form application to work with 2012 SQL Server Reporting Service reports that are remote rdl-formatted reports.

On those rdl report files, there are pre-built custom UI fields such as drop down lists, text boxes, check boxes.  Those UI fields relate with user-input parameters.And the UI parameters are not provided by the report viewer codes; users provide or interact to provide/select data.

A hidden parameter is fed by the asp.net report viewer's code, and is in the report viewer's SubmittingParameterValues event handler as:

protected void ReportViewer1_SubmittingParameterValues(object sender, ReportParametersEventArgs e)
                {
                    if (e != null)
                    {
                        e.Parameters.Add(new ReportParameter("HiddenWebLoginUserIdParameter", webLoginUserIdVariable ));
                    }
                }

The codes for that event work OK whenever users press the "View Report" button on reports.  However, if I add that hidden parameter ("HiddenWebLoginUserIdParameter") on the Page_Load event handler of the aspx page that contains the report viewer, the other user-input UI parameters on the reports are broken (drop down lists are not populated from SSRS, etc.) once reports are run. I would like to pass the hidden parameter from report viewer control so that hidden parameter is available when the aspx web form (that contains the report viewer control) first loads.  The breaking code line looks like (the last code line in the Page_Load event handler):

  

 protected void Page_Load(object sender, EventArgs e)
        {
           ....

                ReportViewer1.ServerReport.ReportPath = "MyReportPath";
                ReportViewer1.ServerReport.ReportServerUrl = new Uri(MyReportServerUrl);

               
                ReportViewer1.ServerReport.SetParameters(new ReportParameter("HiddenWebLoginUserIdParameter", webLoginUserIdVariable ));
            }

            ...
        }  


My question:
I do not know why adding hidden parameter in the Page_Load event handler does not work and breaks other UI field parameters on SSRS reports while doing so in the SubmittingParameterValues event handler does work.  Any help is greatly appreciated.


Viewing all articles
Browse latest Browse all 1418

Trending Articles



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