Articles in this section
Category / Section

How to Load RDLC Report in ReportViewer LightSwitch HTML?

2 mins read

This article helps you to explain the steps for loading RDLC report in ReportViewer LightSwitch HTML Control, process it with local mode and bind the data source to the report.

When you are new to ReportViewer LightSwitch HTML, you can read Getting started with ReportViewer LightSwitch HTML from the previous article available in the following link.

Load RDLC Report

The ReportViewer has an option to load RDL/RDLC reports and process them locally. The following steps help you to load a RDLC report file from server application and bind data to the report at server.

1. Add a New Folder in Server Project and name it as ReportTemplate.

2. Copy and paste the sample RDLC report file Sales Dashboard.rdlc to ReportTemplate folder. Content and resource items in a LightSwitch project are not deployed with the application by default. You can deploy these items by changing some properties for the file. Change the Build Action property for report file as Content and Copy to Output Directory as Copy always.

Paste the RDLC under ReportTemplate folder and change the the properties of the file 

Figure 1: RDLC File Added to Server Project




You can obtain sample rdlc file “Sales Dashboard.rdlc” from Syncfusion samples installed location(%userprofile%\AppData\Local\Syncfusion\LightSwitch\X.X.X.X\HTML\2013\SampleBrowser\SampleBrowser.Server\ReportTemplate). “X.X.X.X” is the Essential Studio Release Version.


3. For processing the RDLC reports locally, you have to set ReportViewer’s reportPath as desired rdlc file name(Sales Dashboard.rdlc) and processingMode as  ej.ReportViewer.ProcessingMode.Local

var itemTemplate = $("<div></div>").attr('id', 'reportContainer')
    itemTemplate.css({ 'width': '100%', 'height': '450px' });
        reportServiceUrl: "../api/SSRSReport",
        processingMode: ej.ReportViewer.ProcessingMode.Local,
        reportPath: "Sales Dashboard.rdlc"


4. Set RDLC file path from sample application at WebApi OnInitReportOptions

public void OnInitReportOptions(ReportViewerOptions reportOption)
             //Map the report path to physical path
           var hostedPath = System.Web.HttpContext.Current.Server.MapPath("~/");
            var rdlPath = hostedPath + "bin\\ReportViewerSample.Server\\ReportTemplate\\" + reportOption.ReportModel.ReportPath;
            reportOption.ReportModel.ReportPath = rdlPath;


5. You can bind the data source to ReportViewer control either at OnInitReportOptions or at OnReportLoaded methods.

public void OnReportLoaded(ReportViewerOptions reportOption)
            //Add data sources to report model
            reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "TopSalesPerson", Value = SalesPersons.GetTopSalesPerson() });
            reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "TopStores", Value = Stores.GetTopStores() });


Run the Application

Run the sample application and you can see the ReportViewer with Sales Dashboard report on the page as displayed in the following screenshot.

Sales Dashboard report is generated in ReportViewer

Figure 2: ReportViewer with Sales Dashboard Report

Demo Sample

You can download the Demo Sample from the following link.

Local Report (RDLC) Sample

Further References

You can find documentation and demo samples for JavaScript, ASP.NET, and ASP.NET MVC ReportViewer Control from the following links.

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment