Report Writer Events

You can handle the Report Writer events with reports using the following events.

  • SubreportProcessing
  • ReportErrorOccurred

Subreport Processing

The SubreportProcessing event occurs when subreport is loaded and it is ready to start the 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. Report Writer instance used to register the SubreportProcessing event 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 ReportErrorOccurred event raises when an error occurs in the 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.
};