New to Telerik Reporting? Download free 30-day trial

Using Report Events

The Report object exposes these events:

Event Description
ItemDataBinding Fires just before the report is bound to data.
NeedDataSource Fires when the report does not have data source set.
ItemDataBound Fires just after the report is bound to data.

The example below shows the NeedDataSource event assigning the report DataSource at runtime. This event only fires when the DataSource is null.

void report_NeedDataSource(object sender, EventArgs e)
{
    Telerik.Reporting.Processing.Report processingReport = (Telerik.Reporting.Processing.Report)sender;
    object processingParameterValue = processingReport.Parameters["parameter1"].Value;
    processingReport.DataSource = GetData(processingParameterValue);
}

static object GetData(object value)
{
    // Implement your custom data retrieval logic instead
    return new string[] { "Sofia", "London", "Tokyo" };
}

{{source=CodeSnippets\VB\API\Telerik\Reporting\Processing\ReportEvents.vb region=NeedDataSourceEventHandlerSnippet}}

Private Sub report_NeedDataSource(sender As Object, e As EventArgs)
    Dim processingReport As Telerik.Reporting.Processing.Report = DirectCast(sender, Telerik.Reporting.Processing.Report)
    Dim processingParameterValue As Object = processingReport.Parameters("parameter1").Value
    processingReport.DataSource = GetData(processingParameterValue)
End Sub

Private Shared Function GetData(value As Object) As Object
    ' Implement your custom data retrieval logic instead
    Return New String() {"Sofia", "London", "Tokyo"}
End Function
In this article