- 3 minutes to read
This document describes how to bind a report to an object implementing any of the following interfaces:
You can use this approach when a physical database does not supply a report’s data. This may be necessary, for example, in a multi-tier application where the data layer is separated from the presentation layer, and it is only possible to bind a report to some .NET objects.
See the Quick Guide to Report Data Binding topic to learn about the other data binding approaches.
You can assign a list object directly to a report’s XtraReportBase.DataSource property:
You do not need to specify the report’s XtraReportBase.DataMember property when binding to a list containing plain data (a non-normalized list).
Each record in such list is an object whose public properties are treated as individual data fields and whose property values become field values. Do the following to supply your report with data created at runtime:
- Declare a class whose instances should represent individual data records. This class’s public properties are treated as data fields.
When you do not need to create a custom list object, you can use an existing object implementing any of these interfaces. For instance, a ArrayList object can serve as the report’s data source, so this step is optional.
- Create a new list instance and fill it with records.
- Assign the list to the report’s XtraReportBase.DataSource property.
You cannot bind a report to a list at design time in Visual Studio. To design a report’s layout and bind its controls to data at design time, do one of the following:
- Create a data source schema of your list and assign it to the report’s XtraReport.DataSourceSchema property. See Quick Guide to Report Data Binding to learn more about using this approach.
- Use the BindingSource component and specify the required object’s type as its data source. Then, assign a filled list to the XtraReportBase.DataSource property at runtime.
The following tutorials demonstrate how to bind a report to a list object:
- Bind a Report to an Array List (Runtime Sample)
- Bind a Report to a Collection that Implements the ITypedList Interface (Runtime Sample)