Pass Barcode Values Dynamically in ASP.NET Core with Bold Reports
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
-
Open the Bold Reports Designer and design your report.
-
Drag and drop a Barcode report item from the toolbox.
-
Create a new parameter, for example
Barcode_Parameter, to receive the barcode value.
Step 2: Configure the Barcode Report Item
-
Select the Barcode report item.
-
Open the Properties panel by clicking the settings icon.
-
Under Basic Settings section, click the expression icon (fx) next to the Text property.
-
Select Expression and bind it to the parameter:
=Parameters!Barcode_Parameter.Value
Step 3: Save and Upload the Report
- Save the report.
- Place the report file, for example
.rdlin thewwwroot/Resourcesfolder of your ASP.NET Core application.
Step 4: Pass Values from the Controller
-
In your controller, implement the
OnReportLoadedmethod 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
-
Build and run your ASP.NET Core application.
-
View the report. The barcode is rendered using the value passed from the application code.
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.