The Report object exposes these events:
| Property |
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.
CopyC#
private void Report1_NeedDataSource(object sender, System.EventArgs e)
{
string sql = @"SELECT Production.Product.Name, Production.Product.ProductNumber FROM Production.Product";
string connectionString = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True";
SqlDataAdapter adapter = new SqlDataAdapter(sql, connectionString);
DataSet dataSet = new DataSet();
adapter.Fill(dataSet);
(sender as Telerik.Reporting.Processing.Report).DataSource = dataSet;
}
CopyVB.NET
Private Sub Report1_NeedDataSource(ByVal sender As Object, ByVal e As System.EventArgs)
Dim sql As String = "SELECT Production.Product.Name, Production.Product.ProductNumber FROM Production.Product"
Dim connectionString As String = "Data Source=(local)\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True"
Dim adapter As New SqlDataAdapter(sql, connectionString)
Dim dataSet As New DataSet()
adapter.Fill(dataSet)
(TryCast(sender, Telerik.Reporting.Processing.Report)).DataSource = dataSet
End Sub