How to use Codeless Barcode Generation feature in ReportViewer RDLC local reports in
How to use Codeless Barcode Generation feature in ReportViewer RDLC local reports in ASP.NET
- Neodynamic Barcode Professional 7.0 for ASP.NET
- Microsoft .NET Framework 2.0 (or greater)
- Microsoft Visual Studio 2008 / 2010
- Microsoft Visual Web Developer (VWD) 2008 / 2010 Express Editions
You can easily generate and display linear, postal & 2D barcodes in RDLC local reports in ASP.NET by using a very simple yet powerful feature called "Codeless Barcode Generation" provided by our Barcode Professional for ASP.NET product.
In short, Codeless Barcode Generation (CBG) is a feature that lets you to render barcode images on ASP.NET or simple HTML pages by just setting up an especial/formatted URL to an HTML's IMG tag without the need of coding VB or C# sentences for barcode rendering. The CBG just needs you add an entry to your web.config file and it will ready to go.
Using CBG in RDLC reports has the following benefits:
- You do not need to write any code! Just add an Image control on your report and set it to the especial/formatted URL provided by CBG. For example, rendering a Code 128 barcode for the value "ID032929" you would do that as follows:
- By using CBG feature, you can easily display barcode images in the Header & Footer sections of the RDLC report, something that requires lots of tricks if using other approaches.
In the following guide, you will learn how to configure CBG feature and use it to generate and display a 2D DataMatrix barcode in the reportís header section and Code 39 linear barcodes for a list of products based on Northwind DB sample. The following figure shows the report with the barcodes:
- That's it! The Codeless Barcode Generation feature is ready to be used!
- Now, create a new RDLC Local report naming it MyBarcodeReport.rdlc
- We'll be displaying a 2D DataMatrix barcode on the header. So, add a Header to the report and add to it an Image control from the toolbox. In the Image control set the source to "External" and the Value to this:
That's the especial/formatted URL which tells to Barcode Professional to generate a 2D DataMatrix barcode for the value "ReportID-091230913". In this case we're using fixed data but you can replace it by a param or any data source field of your report!
- Now, in the body of the report, we'll list products from the Northwind DB sample. For each product, we'll display its code and name. For the code, we'll be generating a linear Code39 barcode.
- First of all, add a new data source to your report. To do that, select View > Report Data from VS 2010 menu bar. In the Report Data pane, click New > Dataset...
- In the Dataset Properties dialog box, click on "New" button for adding a new Data source. In this sample we created a small Access MDB file containing only the Products table of Northwind DB sample which is available here Northwind.mdb
Use it as your data source please by following up the VS wizard.
- After you created a new dataset for your report, please drag & drop a Table control from toolbox onto your report's body. Add the two ProductCode and ProductName fields to the table and add a new Image control for the first column. In the Image control set the source to "External" and the Value to this:
- Finally, open the default.aspx file and add a new ReportViewer control. Set it to display the MyBarcodeReport.rdlc file and set up the data source too! After that, go to the class behind file of such page and add the following line of code into the Page_Load event handler: