Professional Documents
Culture Documents
9/27/2013
Parameter Prompting
When operating in remote mode ReportViewer automatically prompts the user for parameter values unless told not to do so. When operating in local processing mode, ReportViewer does not prompt for parameter values. The rationale is as follows: The most common use of report parameters is to pass to queries as values of query parameters. But unlike the Report Server, the ReportViewer control does not execute queries itself. Rather, queries are executed by the host application, and the result is passed to the ReportViewer control. So the ReportViewer control does not have the opportunity to set query parameters. In local mode the host application must handle parameter prompting, as seen in the example below.
Example
In the example below, the application (an RSS Browser) has a textbox for specifying news items of interest, and a checkbox for turning descriptions on or off. Note that this textbox, checkbox, the url dropdown and the load button are all implemented by the host application. UI features of the ReportViewer control such as toolbar have been turned off in this application. The ability to turn descriptions on or off, and the ability to filter news items are implemented using report parameters. In the RDL the visibility of the description textbox is controlled using a boolean report parameter, like this:
private void checkBox1_CheckedChanged(object sender, EventArgs e) { ReportParameter p = new ReportParameter("ShowDescriptions", checkBox1.Checked ? "true" : "false"); this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p }); this.reportViewer1.RefreshReport(); }
Download source code for this demo application. Descriptions on
Descriptions off
http://www.gotreportviewer.com/localmodeparameters/index.html
1/2
9/27/2013
http://www.gotreportviewer.com/localmodeparameters/index.html
2/2