When creating reports, parameters enable you to control report data, connect related reports together, and vary report presentation. Report parameters can be used to solve tasks such as filtering, conditional formatting, data binding, creating dynamic report layouts, and much more.

In this video, we’ll show how easy it is to work with parameters in ActiveReports. We’ll continue using the report that we generated in our Getting Started - How to Create a .NET Report video.

As a reminder, this is an inventory report using a table that is grouped on product categories. It shows each product’s name, color, price, and size.

We want to filter this report based on color. Therefore, we'll need to create a parameter to indicate that the user needs to select a color, pass that selection to the report, and filter the data based on that parameter.

Step 1: Add a dataset for the parameter values

First, we'll create another dataset specifically for the parameter values. Click the MyDS data source node and select “Add Data Set.” In the DataSet dialog box, rename the data set on the General tab. On the Query tab, I want to query a list of distinct colors from my Products table.

Step 2: How to add parameter

In step two, we need to create a parameter in the report, so the user is prompted to make a selection. In the Report Explorer, right-click the “parameters” node and select “Add Parameter.” On the resulting dialog box’s General tab, we’ll rename the parameter and enter a text that directs the user to make a selection.

On the Available Values tab, we’ll select “From Query” since we created a Dataset for this parameter. We’ll select the Dataset we created earlier from the Dataset drop down.

The Value and Label fields will only have one choice -- since that’s the only field we have selected in our query. Select “color” for both and click OK to close the parameters dialog box.

Step 3: Pass the parameter

Next, we need to edit the Products dataset and pass the parameter to the Products query. On the Products Data Set dialog box, we’ll go to the “Parameters” tab, add a Parameter, rename it, and pass the value from the report parameter created in step 2.

On the Query tab, we’ll add the query parameter, (which we just created) to the where clause. Filter the query based on the value of the parameter selected.

Watch the ActiveReports Using Parameters video tutorial:

Additional tutorials are available on our ActiveReports blog page. Develop and deploy custom enterprise .NET reports with these award-winning complete reporting solutions by downloading a free 30-day trial.

Get ActiveReports Developer

Download the latest version of ActiveReports

Download Now!