How to Create Barcodes for RDLC Reports in ASP.NET Web Forms
Quick Navigate
- BarcodeLib.Barcode.RDLCReports.dll
- Microsoft .NET Framework 2.0 (or later)
- SQL Server 2005 (any edition) with AdventureWorks Database installed
- Microsoft Visual Studio 2005 or later version
2. Create Barcode Image in RDLC Reports for ASP.NET Web Forms
-
Create a new ASP.NET Web Application Project.
- Create a new "ASP.NET Web Site" project, named "BarcodeforRDLCReports".
-
Add a new Class to the project and Add Reference.
- Add a new item (Class), named "SampleClass.cs" to the project.
view image
- Add "BarcodeLib.Barcode.RDLCReports.dll" to the project reference.
- Add the following sample code to your created class "APP_Code/SampleClass.cs".
using System.Collections.Generic;
using BarcodeLib.Barcode.RDLCReports;
using BarcodeLib.Barcode;
- Add the following sample code to your created class "APP_Code/SampleClass.cs".
public class SampleClass
{
private string m_description;
private int m_price;
private byte[] m_bytes;
public SampleClass(string description, int price, string data)
{
m_description = description;
m_price = price;
LinearRDLC barcode = new LinearRDLC();
barcode.Type = BarcodeType.CODE128;
barcode.Data = data;
m_bytes = barcode.drawBarcodeAsBytes();
}
public byte[] Bytes
{
get { return m_bytes; }
}
public string Description
{
get
{
return m_description;
}
}
public int Price
{
get
{
return m_price;
}
}
}
public class Merchant
{
private List<SampleClass> m_products;
public Merchant()
{
m_products = new List<SampleClass>();
m_products.Add(new SampleClass("code128", 25, "code128"));
m_products.Add(new SampleClass("code39", 30, "code39"));
m_products.Add(new SampleClass("qrcode", 15, "qrcode"));
}
public List<SampleClass> GetProducts()
{
return m_products;
}
}
- In Visual Studio menu bar, choose "Build Web Site" from "Build" tab.
view image
-
Add a new Report to the web form.
- Add a new report (Report), named "RDLCReports.rdlc" to the project.
view image
- In Report Items from Toolbox, insert a "Table" to the report.
view image
- In "Website Data Sour...", add "Name" and "Price" to first two columns of the report table details section.
Name the last column "Barcode".
view image
- In "Toolbox", drag an "Image" item to the last column "Barcode".
view image
- Set image properties "MIMEType" to "image/jpeg", "Source" to "Database", and "Value" to "=Fields!Barcode.Value".
Save the report.
view image
-
Add a Report Viewer to the web form.
- In "Solution Explorer", right-click "Default.aspx", and select "View Designer".
- In "Toolbox", add "ReportViewer" to the web form project, with the default setting unchanged.
view image
- In "ReportViewer Tasks" window, choose your created report "RDLCReports.rdlc".
view image
-
Resize the "ReportViewer", and run the project.
3. Property Settings for Each Barcode Types
Copyright BarcodeLib.com. All rights reserved.
|
|