xtrareports-1182-feature-guide-to-devexpress-reports-bind-reports-to-data-business-object-bind-a-report-to-a-list-object.md
This document describes how to bind a report to an object that implements one of the following interfaces:
Important
These objects are non-serializable. In an End-User Report Designer, non-serializable objects are lost when users save a report. Use the ObjectDataSource component as a mediator between your data object and the report or implement a custom serializer to save the data source with the report to a web report storage.
Assign a list object to a report’s XtraReportBase.DataSource property:
Tip
Leave the report’s XtraReportBase.DataMember property unspecified when your list object contains plain data (a non-normalized list).
The following tutorials demonstrate how to bind a report to a list object at runtime:
Declare a class for individual data records. This class’s public properties are treated as data fields.
Declare a class that implements the IList, ITypedList, IBindingList, or IListSource interface. This list serves as the report’s data source. Its elements must be individual data records.
Create a new list instance and populate it with data.
Assign the list to the report’s XtraReportBase.DataSource property.
Create a custom data source component serializer class that implements the IDataSerializer interface. Implement this interface’s methods to save (in the Serialize method) and restore (in the Deserialize method) the data source from the string.
Register your custom data source component serializer class on application startup. For instance, use the Application_Start event in the application’s Global.asax.cs file for this purpose:
Assign the registered serializer’s name to your report before you open the report in the Report Designer:
This approach works for XML serialization only. To save a report with the serialized DataSource, use the XtraReport.SaveLayoutToXml method to save the report definition.
You cannot bind a report to a list at design time in Visual Studio. To design a report layout and bind its controls to data at design time, do one of the following: