Skip to main content

ObjectDataSource Class

Enables binding data-aware controls and components to a runtime-created object or an instance method.

Namespace: DevExpress.DataAccess.ObjectBinding

Assembly: DevExpress.DataAccess.v23.2.dll

NuGet Packages: DevExpress.DataAccess, DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap


[ToolboxBitmap(typeof(ObjectDataSource), "ObjectDataSource.bmp")]
[ToolboxSvgImage("DevExpress.DataAccess.Images.ObjectDataSource.svg,DevExpress.DataAccess.v23.2, Version=, Culture=neutral, PublicKeyToken=c38a27d2243c2672")]
[XRDesigner("DevExpress.DataAccess.UI.Design.XRObjectDataSourceDesigner,DevExpress.DataAccess.v23.2.UI, Version=, Culture=neutral, PublicKeyToken=c38a27d2243c2672", typeof(IDesigner))]
public class ObjectDataSource :



The ObjectDataSource is a data component much like the standard .NET BindingSource component.

The ObjectDataSource component has the following advantages over BindingSource:

  • It can bind to methods that return a collection of custom objects.
  • It can bind to parameterized object constructors.
  • Since it is a cross-platform component, your project does not need the System.Windows.Forms assembly.


The Object Data Source displays only public non-static properties in the Field List.

Refer to the following help topic for examples of use: Use ObjectDataSource.

Data Source for Controls and Components

The following help topics decribe how to use the ObjectDataSource to supply DevExpress controls/components with data:

You can use the Data Source Wizard to bind a component to an Object Data Source. To make a particular assembly, class, or member appear in the Data Source Wizard, use the following attributes: HighlightedAssemblyAttribute, HighlightedClassAttribute, and HighlightedMemberAttribute.

ObjectDataSource Properties

The following properties are used to bind the ObjectDataSource to data.

  • ObjectDataSource.DataSource

    It can be assigned a specific object instance or a type.

    Because the Data Source wizard cannot be used for binding to a specific object instance, it is required to assign this instance to the DataSource property in code before calling the ObjectDataSource.Fill method. In the wizard, this scenario corresponds to the “Retrieve the data source schema” option.

    If the DataSource property has been assigned a type, the ObjectDataSource will try to create an instance of this type when calling the ObjectDataSource.Fill method (this will require specifying the constructor parameters, which is explained further in this article). In the wizard, this scenario corresponds to the “Retrieve the actual data” option.


    If the ObjectDataSource.DataMember property (see below) has been assigned a static member, creating an instance of the corresponding type is not required, nor is specifying the constructor parameters.

  • ObjectDataSource.DataMember

    To bind the ObjectDataSource to an object, leave this property set to null. In the wizard, this scenario corresponds to the following option: “Do not select a member, bind to the entire object”.

    To bind the ObjectDataSource to a property or method, assign its name to the DataMember property. When binding to a method, it is also required to specify this method’s parameters (as described further in this article).

  • ObjectDataSource.Parameters

    To bind to a method, this collection must contain parameters that are required to call this method and obtain the data. In any other case, leave this collection empty.

  • ObjectDataSource.RebuildResultSchema
    Call this method to build the data source schema.
    Call the RebuildResultSchema(IEnumerable<IParameter>) overloaded method instead to apply values from external parameters (for instance, report parameters) to the data source parameters before the schema is built.

  • ObjectDataSource.Constructor

    If it is required that on calling the ObjectDataSource.Fill method, an ObjectDataSource should create an instance of the type specified by its ObjectDataSource.DataSource property, use the Constructor property to specify the required constructor parameters. To assign a constructor without parameters, use the static ObjectConstructorInfo.Default object.

    View Example: How to Create a Report Bound to the ObjectDataSource with Constructor Parameters Linked to Report Parameters

    Set this property to null for the ObjectDataSource to never try to create an object instance (if you need to manually create and assign it, or when binding to a static member).


See Also