Report Writer Events

The Bold Reports® ASP.NET MVC Report Writer raises the following events, which you can handle to set subreport data sources and parameters or to get report error details.

  • SubreportProcessing
  • ReportErrorOccurred

Subreport Processing

The Report Writer raises the SubreportProcessing event when a subreport is loaded and ready to start processing. You can handle the event and specify the data source, parameters, and subreport loading. The following sample code loads a subreport by assigning the report data source credentials and parameter values in the SubreportProcessing event.

  1. Register the SubreportProcessing event on the Report Writer instance in your Report Writer application.

    writer.SubreportProcessing += (sen, arg) =>
    {
        // Assign the data source and parameter values to the sub report.
    };
  2. Set the subreport data source details to the subreport processing event argument.

    writer.SubreportProcessing += (sen, arg) =>
    {
        arg.DataSources.Add(new BoldReports.Web.ReportDataSource {Name= "Datasource name", Value = value });
    }

    Data source Name is case sensitive and it should be same as in the data source name in the report definition. The Value accepts IList, DataSet, and DataTable inputs.

  3. Set the subreport parameters value to the subreport processing event argument.

    writer.SubreportProcessing += (sen, arg) =>
    {
        arg.Parameters.Add(new BoldReports.Web.ReportParameterInfo { Name = "Parameter name", Values = values});
    }

Report Error

The Report Writer raises the ReportErrorOccurred event when an error occurs in report processing. You can handle the event and get the report error details from the event arguments. Refer to the following sample code to handle the report errors in the ReportErrorOccurred event.

writer.ReportErrorOccurred += (sen, arg) =>
{
   // You can handle the report errors using event arguments.
};

See also