Silent Parameters in SilverlightViewer
ActiveReports popular for its flexibility allows developers to do various kind of customizations to completely control the report processing engine to fit their needs. This blog looks to showcase a requirement where developer would like to pass a parameter directly to a SectionReport without requiring end users to input the values. Ideally, with parameteric report, a side bar is displayed where users can input the parameter values. However, this blog shows, how to pass parameters to a SectionReport in a Silverlight application without asking for user inputs. For this blog implementation, we have a combobox with the name of few cities. Selecting a city will fetch the report containing the corresponding records for that city. Before we look ahead with the implementation, lets see how our final output would appear.
Design the Silverlight Page
To begin with, create a Silverlight application with Web Project included. Add a ComboBox control and a SilverlightViewer object to the MainPage of the Silverlight project.
Add SectionReport to the Web Project
In this phase, you add a SectionReport and design all the required fields. However, we will not add any datasource details in this Report. DataSource will be assigned at runtime. You simply have to design the layout by setting the textboxes and mapping their DataField property to the column names in the datasource.
Working with Parametric WebForm
In this blog implementation, the core concept is to pass the parameter as query string to a web form which will run the reports object using the parametric query string in its datasource command. Report is saved in RDL format and returned back as stream to be consumed by the Silverlight Page. Add a web form 'ReportParameters.aspx' and use the code mentioned below. Following code block is the heart of this blog implementation.
Generate Report Based on ComboBox Selection
This section shows how the query string is passed to the webform and retrieve the RDL stream for display in the Silverlight Viewer
Similarly for multiple parameters, you can use multiple query string objects while redirecting to the query web form page. Refer to the attached sample for complete implementation. Download Sample