Step By Step SSRS in 11 Hours: Hour 7

Step By Step SSRS in 11 Hours: Hour 7

Introduction

First, we create the first report with a country list then create another one for the state list based on the parameter passed, in other words, country row id and then display the state report as a sub-report.

Contents

Sub Report in SSRS

Step 1

To add the report, right-click on "Reports", select "Add" and click on "New Item".

image.png

Step 2

Select "Report" and provide the report name.

image.png

Step 3

Add a data source to the report data, right-click on "Data Sources" and click on "Add Data Source".

image.png

Step 4

Provide a data source name and select shared data source reference.

image.png

Step 5

Add a dataset in the report data, right-click on "Datasets" and click on "Add Dataset".

image.png

Step 6

Provide a dataset name and select shared dataset.

image.png

Step 7

Right-click on the design surface, select "Insert" and click on "Table".

image.png

Step 8

Set "Country Row ID" as the column header and map the "CountryRowID" field for that column.

image.png

Step 9

Set "Country Name" as the column header and map the "CountryName" field for that column.

image.png

Step 10

Select and delete the third column.

image.png

Step 11

Now the design of the main report is ready with the columns "Country Row ID" and "Country Name".

image.png

Step 12

To check the report click on the "Preview" tab and we will have a country list.

image.png

Step 13

  • Now let's create a state report with the parameter CountryRowID.
  • To add a report, right-click on "Reports", select "Add" and click on "New Item".

image.png

Step 14

Select "Report" and provide the report a name.

image.png

Step 15

To add a parameter, right-click on "Parameters" in Report Data and click on "Add Parameter".

image.png

Step 16

Provide a parameter name and select its visibility as visible.

image.png

Step 17

  • Add a data source in report data.
  • Right-click on "Data Sources" and click on "Add Data Source".

image.png

Step 18

Provide the data source a name and select data source reference.

image.png

Step 19

  • Add a data set in the report data.
  • Right-click on "Datasets" and click on "Add Dataset".

image.png

Step 20

Provide a data set name and select shared data set.

image.png

Step 21

  • Open the report file.
  • Right-click on the design surface, select "Insert" and click on "Table".

image.png

Step 22

  • It will add a table on the report design surface.
  • Set "State Row ID" and "State Name" in two separate column headers.
  • Map "StateRowID" in the first column.

image.png

Step 23

Map "StateName" in the second column.

image.png

Step 24

Select and delete the third column.

image.png

Step 25

Now the report design is ready.

image.png

Step 26

  • Click on preview to check the report.
  • Pass some parameter value.

image.png

Step 27

You can see the list of states for the country you passed in the parameter.

image.png

Step 28

  • Add one more parameter in Report Data.
  • Right-click on "Parameters" and click on "Add Parameter".

image.png

Step 29

Select "General", provide a parameter name and select its visibility to "Hidden".

image.png

Step 30

  • Select "Default Values".
  • Select the "Specify values" option and specify "0" as the value.

image.png

Step 31

Open "CountryMasterReport.rdl", right-click on "CountryRowID" and click on "Text Box Properties".

image.png

Step 32

  • In the text box properties select "Action".
  • Select "Go to report" in Enable as an action.
  • Specify "CountryMasterReport".
  • Map the parameter with "CountryRowID".

image.png

Step 33

Right-click on the report design surface, select "Insert" and click on "Subreport".

image.png

Step 34

Right-click on the subreport area and select "Subreport Properties".

image.png

Step 35

Select "General", provide the appropriate name.

Select the report that we want to display as a subreport, in other words "RptCountryDetailReport".

image.png

Step 36

Select "Parameters" and map the parameter for CountryRowID.

image.png

Step 37

Now our complete report design is ready.

image.png

Step 38

  • Click on the "Preview" tab and you can see the country list.
  • Now click on any of the country row ids and the state list is shown as a sub report.

image.png

Next >> Hour 8: Report with style