Skip to main content

Binding to Object Data Sources

  • 2 minutes to read

The Dashboard Designer allows you to connect to an object data source defined in a separate class within the current project.

Creating a Data Source in the Data Source Wizard

To bind a dashboard to an object data source, do the following.

  1. Click the New Data Source button in the Data Source ribbon tab.

    DataBinding_NewDataSource

  2. On the first page of the invoked Data Source Wizard dialog, select Object Binding and click Next.

    DataSourceWizard_DataSourceType_Object

  3. On the next page, select the assembly containing the definition of the required class.

    DataSourceWizard_Object_SelectAssembly

    Click Next.

  4. Select the class providing the required data and click Next.

    DataSourceWizard_Object_SelectClass

    For instance, this can be a custom class providing the required data or any TableAdapter used to query a database.

  5. On the final page, select the required data member used to obtain data and click Finish.

    DataSourceWizard_Object_SelectDataMember

    This creates the data source and displays its fields in the Data Source Browser.

    Note

    The collection returned by a data class must implement the IEnumerable or IListSource interface.

Creating a Data Source in Code

To create an object data source in code, create an instance of the DashboardObjectDataSource class and specify the following properties:

Finally, add the created DashboardObjectDataSource object to the Dashboard.DataSources collection.

The following code snippet shows how to create an object data source and add it to the collection of dashboard data sources:

using DevExpress.DashboardCommon;
// ...
            Dashboard dashboard = new Dashboard();
            DashboardObjectDataSource objectDataSource = new DashboardObjectDataSource();
            objectDataSource.DataSource = typeof(Student);
            objectDataSource.DataMember = "GetData";
            objectDataSource.Constructor = ObjectConstructorInfo.Default;
            objectDataSource.Fill();
            dashboard.DataSources.Add(objectDataSource);