Telerik Reporting R1 2017

Binding a Data item to Data

You can work with a data item by binding it to a data source component such as an ObjectDataSource or a SqlDataSource. The data source component connects to a data source such as a database or middle-tier object to retrieve the data. The data-bound item will then use this data. To perform the binding, you need to set the data item's DataSource property to point to a data source component. When a data-bound item is bound to a data source component, little or no additional code is required for data operations, because the data-bound item can automatically take advantage of the data services provided by the data source component.

Note Note

For backwards compatibility reasons Telerik Reporting supports binding directly to IEnumberable/IListSource objects (incl. arrays, collections, DataSet, DataTable, DataView, and DbDataAdapter). Instead consider using the ObjectDataSource that can handle these types of data sources.

Binding to data at design-time

Data Source Components are used to connect to data at design-time. Having valid data source attached to a Data Source Component at design-time allows you to take advantage of all design time features and work with the Data Explorer. For more information please see Data Source Components and DataSource Wizard. After you create and configure a data source component via its wizard you can assign it to the data item's DataSource property using the Properties window in the report designer.

Binding to data at run-time

To bind a data item to data at run-time, you need to access the DataSource property of the data item and set its value programmatically. For more information on how to access data items please see Accessing Report Items Programmatically.

Binding to data from the parent data item

Oftentimes the data needed for your Table, Chart, or another data item will already be present in the parent's data source e.g., the report's data source. In such cases, you can improve the report performance by reusing the data from the parent, instead of creating and configuring a new data source component to retrieve the data anew. You can reuse the data by adding a Binding to the data item's DataSource property, which sets the following expression:

= ReportItem.DataObject

The DataObject property is an object instance representing the data that an item is bound to when processed. Depending on the Data Scope in which the data item is present, DataObject may return all of the parent's data or a selection of its data rows. For example, binding a Graph located inside a report group will result in the Graph retrieving data only for the current report group instance. For more information please see How to use the ReportItem.DataObject property in expressions.