Articles in this section
Category / Section

Pass Barcode Values Dynamically in ASP.NET Core with Bold Reports

Published:
Updated:

Bold Reports enables dynamic barcode generation by passing values from your ASP.NET Core application code. This approach allows you to generate real-time, personalized barcodes such as unique order IDs or ticket numbers while supporting scalability, error validation, and flexible formatting. It is well suited for inventory management, ticketing systems, and labeling workflows, ensuring barcodes remain accurate and up-to-date.

Steps to Pass Barcode Values Dynamically

Step 1: Create a Report with a Barcode Report Item

  1. Open the Bold Reports Designer and design your report.

  2. Drag and drop a Barcode report item from the toolbox.

  3. Create a new parameter, for example Barcode_Parameter, to receive the barcode value.

    Creating Parameter

Step 2: Configure the Barcode Report Item

  1. Select the Barcode report item.

  2. Open the Properties panel by clicking the settings icon.

  3. Under Basic Settings section, click the expression icon (fx) next to the Text property.

  4. Select Expression and bind it to the parameter:

    =Parameters!Barcode_Parameter.Value
    

    Binding Parameter to Barcode

    Expression Editor

Step 3: Save and Upload the Report

  1. Save the report.
  2. Place the report file, for example .rdl in the wwwroot/Resources folder of your ASP.NET Core application.

Step 4: Pass Values from the Controller

  1. In your controller, implement the OnReportLoaded method to set the parameter value dynamically:

    public void OnReportLoaded(ReportViewerOptions reportOption)
    {
        List<BoldReports.Web.ReportParameter> userParameters = new List<BoldReports.Web.ReportParameter>();
        userParameters.Add(new BoldReports.Web.ReportParameter()
        {
            Name = "Barcode_Parameter",
            Values = new List<string>() { "1123456789" }
        });
        reportOption.ReportModel.Parameters = userParameters;
    }
    

    Tip: Replace "1123456789" with a dynamic value, such as data retrieved from a database or user input.

Step 5: Build and Run the Application

  1. Build and run your ASP.NET Core application.

  2. View the report. The barcode is rendered using the value passed from the application code.

    Rendered Barcode

Conclusion

Passing barcode values dynamically from ASP.NET Core code to Bold Reports streamlines real-time barcode generation. This integration improves efficiency for applications that require unique, data-driven barcodes while maintaining accuracy and flexibility.

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied