Friday, July 17, 2015

5 simple steps to Create RDLC Report in

In this article I am going to explain the 5 simple steps to Create RDLC Report in

In the previous article I have explained Implement Google like Custom Pagination in Datalist Control in and Highlight The Current (selected) Page Number in Repeater Pagination.

I have created a table Student_Detail and having data. I want to display the detail of Students in Report. To create a report using RDLC follow the below given steps.

Step 1: Add Dataset to project/website.
Go to Add new item and add the Dataset to project. In this example DsStudentDetail .xsd is the name of dataset.  
5 simple steps to Create RDLC Report in

When you click on Add button you get a popup to place the Dataset file in App_Code folder. Click on Yes.

Step 2: Add Datatable to added Dataset (DsStudentDetail .xsd).
Right click on Dataset and add a DataTable to it.

Step 3: Add column/columns to DataTable
Right click on DataTable go to Add >> Column. Give a name to column’s but keep in mind columns names must match the name of columns of table. By default DataType of all columns are String if you want change the datatype of any column go to properties of that particular column.

Step 4: Add RDLC Report to website/project
Now go to Add new item and add the RDLC report to website. In this tutorial I am going to add the Reports (RDLC) Wizard.

Report wizard will open. Select the Datasource as Dataset (DsStudentDetail .xsd).  After that Click on Next button.

Now arrange the fields on this step. Drag and drop the required fields from available fields to values section. Hit the next button.

Click on next button if you don’t want to show the grand total and subtotal.

Choose the style in this step and click on Finish button.

Report.rdlc is added to the website. 

Step 5: Add webform
Add webform to website. Drag and drop the ReportViewer control from ToolBox (Reporting) and ScriptManager to webform.  ReportViewer control requires ScriptManager.

Complete HTML markup of webform:
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>
Add the namespace to code file
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Microsoft.Reporting.WebForms;
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports Microsoft.Reporting.WebForms

Write the code to Get the data from database and bind to Reportview.
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ToString());
    protected void Page_Load(object sender, EventArgs e)
    private void BindReport()
            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            //report path
            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
            SqlDataAdapter adp = new SqlDataAdapter("Select * from Student_Detail", con);
            //object of Dataset DsstudentDetail
            DsStudentDetail ds = new DsStudentDetail();
            adp.Fill(ds, "DataTable1");
            //Datasource for report
            ReportDataSource datasource = new ReportDataSource("DataSet1", ds.Tables[0]);
            ReportViewer1.Width = 600;
        catch(Exception ex)

    Private con As New SqlConnection(ConfigurationManager.ConnectionStrings("connection").ToString())
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
        End If
    End Sub
    Private Sub BindReport()
            ReportViewer1.ProcessingMode = ProcessingMode.Local
            'report path
            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc")
            Dim adp As New SqlDataAdapter("Select * from Student_Detail", con)
            'object of Dataset DsstudentDetail
            Dim ds As New DsStudentDetail()
            adp.Fill(ds, "DataTable1")
            'Datasource for report
            Dim datasource As New ReportDataSource("DataSet1", ds.Tables(0))
            ReportViewer1.Width = 600
        Catch ex As Exception
        End Try
    End Sub

All is done. Now build the project and run.  
5 simple steps to Create RDLC Report in

  In this article we have learn 5 simple steps to create RDLC report in, VB). I hope you enjoyed this article. 

1 comment:

  1. this article will have result, because every thing has done at the end don't wast your time search for new