Home > .NET RDLC Reports Barcode > .NET, C#, VB.NET Barcode Library for RDLC Reports for ASP.NET

How to Create Barcodes in RDLC Reports for ASP.NET Web Form Applications?





RDLC Local Report Barcode Generator Library

QR Code, Data Matrix, Code 128, GS1, EAN/UPC. Unicode text encoding in C# RDCL Local Report ASP.NET, MVC web application.

Download Now
NuGet Ready
.NET Framework 4.x, 3.x, 2.x

Here we will show you the detailed procedure for creating and printing barcodes within RDLC reports in an ASP.NET framework web application.


Prerequisites

  • BarcodeLib.Barcode.RDLCReports.dll
  • Microsoft .NET Framework 4.x, 3.x, or 2.x
  • Microsoft Visual Studio 2026, 2022, 2019, 2017 or early version


1. Create a New ASP.NET Project

  1. Launch Visual Studio 2022.
  2. Select Create a new project.
  3. In the project template dialog, choose ASP.NET Web Application (.NET Framework).

  4. Click the Next button.
  5. Name the project BarcodeLibRDLCBarcodeAspnetDemo.

  6. Set the Framework to .NET Framework 4.7.2.
  7. Create an empty ASP.NET web application with default settings.

  8. After creation, verify that all auto-generated files appear in the Solution Explorer.



2. Add Required NuGet Packages and Libraries

  1. In the Solution Explorer, right-click References and select Manage NuGet Packages.
  2. Click Browse and search for Microsoft.ReportingServices.ReportViewerControl.WebForms using the search box. Ensure the package source is 'nuget.org'.

  3. Install the latest stable version of this package.
  4. Add barcode library dll BarcodeLib.Barcode.RDLCReports.dll to the project reference.

  5. Confirm successful installation by checking the References node in the Solution Explorer.


3. Print Barcodes from a DataTable in RDLC Report (C# ASP.NET)

3.1 Add a Data Source to the Project

  1. Add a new item of type DataSet1.xsd to the project.

  2. Inside DataSet1.xsd, add a new data table. The default table name is DataTable1.

  3. Add a column named Website to DataTable1 and set its Data Type property to System.String.
  4. Add another column named Barcode and set its Data Type to System.Byte[].
  5. The resulting DataTable1 contains exactly two columns: Website (string) and Barcode (byte array).



3.2 Design the RDLC Report

  1. Add a new report item named Report1.rdlc to the project.

  2. Set the Copy to Output Directory property to Copy if newer.

  3. Select Add Dataset to open the Dataset Properties dialog.

  4. In the dialog, choose DataSet1 from the Data source combo-box and DataTable1 from the Available datasets combo-box.

  5. Insert a Table control into the report designer.

  6. Drag the fields Website and Barcode into the table in the designer.

  7. Insert an Image control into the Barcode field.

  8. Configure the image properties as follows:
    • In Image Properties, set Image source to Database.
    • Set MIME type to image/png.
    • For the Field option, select Barcode.
  9. Finally, adjust the table row height and column width to appropriate sizes.


3.3 Add a Web Form to the ASP.NET Project

  1. Add a new Web Form item named Default.aspx to the project.

  2. In the ASPX file, inside the form with id="form1", add a ScriptManager control and a ReportViewer control with ID="ReportViewer1".

    Replace the content of Default.aspx with the following codes:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BarcodeLibRDLCBarcodeAspnetDemo.Default" %>
    <%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>BarcodeLib RDLC Report Barcode Generator in ASP.NET Website</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <rsweb:ReportViewer ID="ReportViewer1" Width="1600px" Height="1200px" runat="server" />
    </div>
    </form>
    </body>
    </html>
    


3.4 Replace the Code-Behind Class

  1. Replace the contents of the code-behind file Default.aspx.cs with the C# code below.

    using BarcodeLib.Barcode;
    using Microsoft.Reporting.WebForms;
    using BarcodeLib.Barcode.RDLCReports;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Drawing.Imaging;
    namespace BarcodeLibRDLCBarcodeAspnetDemo
    {
        public partial class Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    // Prepare report data.
                    DataTable dt = new DataTable();
                    dt.Columns.Add("Website", typeof(String));
                    dt.Columns.Add("Barcode", typeof(byte[]));
                    String id1 = "https://www.barcodelib.com";
                    String id2 = "https://www.google.com/";
                    String id3 = "https://www.youtube.com/";
                    // Create data for the 1st row in the table.
                    LinearRDLC barcode = new LinearRDLC();
    
    
                    barcode.Type = BarcodeType.CODE128;
    
                    barcode.ImageWidth = 600;
                    barcode.ImageHeight = 100;
                    barcode.ImageFormat = ImageFormat.Png;
    
                    barcode.Data = id1;
                    byte[] imgData = barcode.drawBarcodeAsBytes();
                    dt.Rows.Add(id1, imgData);
    
                    // Create data for the 2nd row in the table.
                    barcode.Data = id2;
                    imgData = barcode.drawBarcodeAsBytes();
                    dt.Rows.Add(id2, imgData);
    
                    // Create data for the 3rd row in the table.
                    barcode.Data = id3;
                    imgData = barcode.drawBarcodeAsBytes();
                    dt.Rows.Add(id3, imgData);
    
                    // Configure Report
                    ReportDataSource rds = new ReportDataSource("DataSet1", dt);
                    this.ReportViewer1.LocalReport.DataSources.Clear();
                    this.ReportViewer1.LocalReport.DataSources.Add(rds);
                    this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report1.rdlc");
                    this.ReportViewer1.LocalReport.Refresh();
                }
            }
        }
    }
    


3.5 Configure the Web.config File

  1. Copy all contents within the and configuration tags into the application's Web.config file.

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      https://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
    	<system.web>
    		<compilation debug="true" targetFramework="4.7.2">
    			<assemblies>
    				<!-- All assemblies updated to version 15.0.0.0. -->
    				<add assembly="Microsoft.ReportViewer.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
    				<add assembly="Microsoft.ReportViewer.DataVisualization, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
    				<add assembly="Microsoft.ReportViewer.Design, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
    				<add assembly="Microsoft.ReportViewer.ProcessingObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
    				<add assembly="Microsoft.ReportViewer.WebDesign, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
    				<add assembly="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
    				<add assembly="Microsoft.ReportViewer.WinForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
    			</assemblies>
    			<buildProviders>
    				<!-- Version updated to 15.0.0.0. -->
    				<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
    			</buildProviders>
    		</compilation>
    		<httpRuntime targetFramework="4.7.2" />
    		<httpHandlers>
    			<!-- Version updated to 15.0.0.0 -->
    			<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" validate="false" />
    		</httpHandlers>
    	</system.web>
    	<system.webServer>
    		<validation validateIntegratedModeConfiguration="false" />
    		<modules runAllManagedModulesForAllRequests="true" />
    		<handlers>
    			<!-- Version updated to 15.0.0.0 -->
    			<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
    		</handlers>
    	</system.webServer>
    </configuration>
    


4. Run the RDLC Report in the ASP.NET Application

  1. Press Ctrl+F5 to execute the project.
  2. The RDLC report with barcode images generated from the DataTable. will be displayed via the ReportViewer control.
  3. A screenshot of the resulting RDLC report demo in the ASP.NET application is shown for reference.










Other .NET Barcode Generator Components