Click here to Skip to main content
15,844,602 members
Articles / Web Development / ASP.NET

Using RDLC Report in .NET 4.0

Rate me:
Please Sign up or sign in to vote.
3.50/5 (2 votes)
19 Nov 2012CPOL 51.4K   18   4
Using RDLC report in .NET 4.0 version in ASP.NET and C#.


Using RDLC report in .NET 4.0 is quite different in comparison to prior versions of .NET. Since RDLC reports have their own importance, here are some easy steps to use them.

Using the code 

Please follow the below steps:

  1. Take .Xsd file (typed dataset) and create a table in this Typed dataset. This file must be in the App_Code folder.
  2. Build your Project/website.
  3. Now take .aspx Page and add reportviewer control in this file and choose RDLC report from reportviewer control.
  4. In RDLC wizard select Dataset (.xsd file added by you).
  5. Add All Column of Dataset (of .xsd) in required postion in RDLC file(you can tool table/text boxes from RDLC toolbox).
  6. Now Fill .xsd DataSet in code behind file.(please take care of this. see DataSet using in c#. I took same table name what is in my typed DataSet).
  7. Use Script Manager (in aspx file) as this is manadatory.
  8. Also use !IsPostBack in Page load to avoid infinte loop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.Reporting.WebForms;

public partial class Report_RDLC_Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
            if (!IsPostBack)
                DataSet DsTest = new DataSet("dtTest");
                DataTable dtTest = new DataTable("dtTest");
                dtTest.Columns.Add("EmpName", System.Type.GetType("System.String"));
                dtTest.Columns.Add("EmpId", System.Type.GetType("System.Int32"));
                dtTest.Columns.Add("EmpSal", System.Type.GetType("System.Double"));

                DataRow dr;
                for (int iIndex = 0; iIndex < 99; iIndex++)
                    dr = dtTest.NewRow();
                    dr["EmpId"] = "100" + iIndex.ToString();
                    dr["EmpName"] ="Kapil Dev-  "+  iIndex.ToString();
                    dr["EmpSal"] = (iIndex * 32678).ToString();

                ReportViewer1.Visible = true;
                ReportDataSource datasource = new ReportDataSource("DataSet1", DsTest.Tables[0]);

<%@ Page Language="C#" AutoEventWireup="true" 
  CodeFile="Default.aspx.cs" Inherits="Report_RDLC_Default" %>

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

tagprefix="rsweb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<html xmlns="">
<head runat="server">
    <style type="text/css">
            width: 100%;
            height: 34px;
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" >
   <div style="text-align:center;width:80%;">
        <table style="width:60%;text-align:center;margin:0px 0px 0px 200px;">
        <td style="text-align:center" >
           <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
            Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
            WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" 
                BackColor="#CCCCFF" Height="600px" Width="100%">
            <LocalReport ReportPath="Report_RDLC\Report1.rdlc">


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Technical Lead Tech Mahindra
India India
Working in Tech mahindra, Noida, India. Having more than 7 years knowledge in asp,,C#, VB 6.0, VB.Net, XSLT, XML, RDLC report, Crystal Report, SQL Server, MySql, DB2 etc.

Comments and Discussions

GeneralMy vote of 2 Pin
Marcio Wesley Borges6-Oct-14 9:13
professionalMarcio Wesley Borges6-Oct-14 9:13 
Article can be more useful if better developed.
QuestionCreating New Page for new Information of report.rdlc Pin
mhamidnasir26-May-14 2:03
mhamidnasir26-May-14 2:03 
QuestionUsing Business Objects Pin
Member 207364411-Apr-13 7:46
Member 207364411-Apr-13 7:46 
QuestionSend to printer Pin
david4life20-Nov-12 7:30
david4life20-Nov-12 7:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.