Create Custom Template in SSRS

This article shows how to create custom templates in SSRS. But before creating a custom template we need to understand why we need to create custom templates.

Why we need to create custom templates in SSRS

A custom template is like an ASP.NET Master Page where I can put tasks like a common design (Report Header, Report Color, Report Font type and size and so on) for all reports. To maintain consistency in all reports we need to create custom templates in SSRS so that we can reuse the template in all reports. The most important point is that we can save time if we create a custom template.

Now we will learn how to create a custom template for SSRS report and use it.

Step 1

Add a new report to your report project's application.



Step 2

Then insert the table in the report designer. You can create the report depending on business requirements. Here I will use a table in the report that I want to show in tabular format. In this custom report I will implement various things that are common for all reports.

  • Apply Table alternate row color formatting and table header formatting.
  • Remove question (?) mark from the report viewer. Click here for this.
  • A page header should be visible on each page of the report. Click Here for this.
  • Display 10 records on each page of report. Click Here for this.
  • Add a common parameter that is common for all reports.

Apply Table row color formatting and table header formatting

To apply table row color formatting and table header formatting we need to add a table to the report.



Then apply color formatting to the table rows.

Select a row and set a background color for the row. Here I want to set alternate colors to the rows. For this we need to write an expression.



Click on the Expression link.



Then add this =IIF(RowNumber(Nothing) mod 2=0,"#dde8ee","#b9cee1")

The expression in the Expression window for alternate colors of the rows.

We can also set the text formatting of a row.

Add common parameter that is common for all report

Here I will add a common parameter to the report that is common for all reports.

Parameter name: SortOrder.



Add two values, Asc for ascending order and Desc for Descending order.



Then set a default value for the parameter.



We can add various things in the common custom template depending on requirements.

Place the custom template
 
After template creation we need to place this custom template in a specific location of your system.

The location is: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\ProjectItems\ReportProject

Copy and paste the custom template at this location.



Now we can use this template in own report.

Go to the Report folder and add a new report.



Here we can see the custom report template in this window.



Select the custom report and build the report using this custom report.



Now we need to add a data set and bind it to the table of the report.


Similar Articles