Creating an RDLC report in Asp.Net - Blogs

Creating an RDLC report in Asp.Net

Step 1.  Create a new website and Add DataSet to the Website

Right Click on the project, Add new item Dataset, and name it as Employees.xsd.

Step 2. Adding DataTable to the DataSet

Our next step would be to add a DataTable to the Type DataSet.



Step 3. Adding Columns or fields to DataTable

In the DataTable we need to specify the column names that we want to display in the Report.


Step 4. Adding the RDLC Report

Right click on the project and Add New Item, Report Wizard where we configure our report.


Step 5. Choose the DataSet

Now we need to choose the DataSet that will act as the DataSource for the RDLC Report. Thus we need to select the Customers DataSet that we have created earlier.


Step 6. Choose the Fields to be displayed in the RDLC Report

Next we need to choose the fields we need to display, we need to simply drag and drop each fields into the Values Box as shown in the screenshot below


Step 7. Choose the Layout

The next dialog will ask us to choose the layout, we can simply skip it as of now as this is a simple Report with no calculations involved.


Step 8. Choose the Style

Finally we need to choose the style, i.e. color and theme of the Report.


Once you press Finish button on the above step, the Report is ready and is displayed in the Visual Studio as shown below


Step 9. Adding Report Viewer to the page

Add new webform into the project and add ReportViewer and ScriptManager  control to the page from the Toolbox. The ReportViewer controls requires ScriptManager on the page.

Once you add the ReportViewer control to the page, your page must look as below

%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Webform.aspx.cs" Inherits="RDLCreport.Webform" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>























Step 10. Getting data from database to RDLC report.

Below is the code to data from database to RDLC report. The first statement notifies the ReportViewer control that the Report is of type Local Report.

Then the path of the Report is supplied to the ReportViewer, after that the Employees DataSet is populated with records from the Employees Table is set as ReportSource to the Report.



using System.Data;

using System.Configuration;

using System.Data.SqlClient;

using Microsoft.Reporting.WebForms;


protected void Page_Load(object sender, EventArgs e)


    if (!IsPostBack)


        ReportViewer1.ProcessingMode = ProcessingMode.Local;

        ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/LocalReport.rdlc");

        Employees dsEmployees = GetEmployees("select top 10 * from employees");

        ReportDataSource datasource = new ReportDataSource("Employees", dsEmployees.Tables[0]);






private Employees GetEmployees(string query)


    string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;

    SqlCommand cmd = new SqlCommand(query);

    using (SqlConnection con = new SqlConnection(conString))


        using (SqlDataAdapter sda = new SqlDataAdapter())


            cmd.Connection = con;

            sda.SelectCommand = cmd;

            using (Employees dsEmployees = new Employees())


                sda.Fill(dsEmployees, "DataTable1");

                return dsEmployees;





Your RDLC report has been displayed below in the browser


Thank You



What are Frames? How to handle frames in Selenium WebDriver with C#?

IFrame (FullForm: Inline Frame) is an HTML document that is included in another HTML document and is...

Read More >

What is Synchronization? Handling Synchronization in Selenium WebDriver using C#:

Synchronization meaning: when two or more components involved to perform any action, we expect these...

Read More >

Sending Test reports by Email using Office 365, Gmail

Wouldn’t it be great if Test Report are sent automatically across team as soon the Test Execut...

Read More >

ASP.NET: Audit Trail Implementation using Entity Framework

When you are working with certain projects which involves the Customer records, you might need to tr...

Read More >

Create Restful service using Web API

What is Asp.Net Web API?Asp.Net Web API is a framework for building HTTP services that can be consum...

Read More >

Create custom project templates in Visual Studio

Visual studio installation comes with the various predefined project templates, and we can use one o...

Read More >

WCF SOAP and REST Services

WCF (Windows Communication Foundation) is a programming platform and runtime system for building, co...

Read More >

What's New In C# 6.0?

Microsoft has released the preview version of Visual Studio 2015 and .NET 4.6 for developers to try ...

Read More >

How to add Overlay in Windows phone 8

Windows Phone is windows mobile operating system from Microsoft.In my project, there was a requireme...

Read More >

Converting UserControl into a dll

User controls are containers into which you can put markup and Web server controls. You can then tre...

Read More >


Try DevOpSmartBoard Ultimate complete Azure DevOps End-to end reporting tool

Sign Up

  • Recent
  • Popular
  • Tag
Monthly Archive

Contact Us
  • *
  • *