Skip to main content
A newer version of this page is available. .

DataDashboardItem.DataSource Property

Gets or sets a data source to which the dashboard item is bound.

Namespace: DevExpress.DashboardCommon

Assembly: DevExpress.Dashboard.v21.1.Core.dll

NuGet Package: DevExpress.Dashboard.Core

Declaration

[DefaultValue(null)]
public IDashboardDataSource DataSource { get; set; }

Property Value

Type Default Description
IDashboardDataSource *null*

An object implementing the IDashboardDataSource interface that specifies a data source to which the dashboard item is bound.

Remarks

All data-aware dashboard items expose the DataSource property that specifies a data source to which this item is actually bound. The DataDashboardItem.DataMember property specifies the required data member in this data source.

To access the collection of existing dashboard data sources, use the Dashboard.DataSources property.

Note

For DashboardSqlDataSource or DashboardEFDataSource, specify the required data member using the DataDashboardItem.DataMember property.

Example

The following example demonstrates how to bind a Choropleth Map dashboard item to data in code.

View Example

using System.Windows.Forms;
using DevExpress.DashboardCommon;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;

namespace Dashboard_CreateChoroplethMap {
    public partial class Form1 : DevExpress.XtraEditors.XtraForm
    {
        public Form1() {
            InitializeComponent();

            Dashboard dashboard = new Dashboard();

            DashboardSqlDataSource dataSource = new DashboardSqlDataSource();
            CustomSqlQuery sqlQuery = new CustomSqlQuery("Countries", "select * from Countries");
            dataSource.ConnectionParameters = new Access97ConnectionParameters(@"..\..\Data\countriesDB.mdb", "", "");
            dataSource.Queries.Add(sqlQuery);

            ChoroplethMapDashboardItem choroplethMap = new ChoroplethMapDashboardItem();
            choroplethMap.DataSource = dataSource;
            choroplethMap.DataMember = "Countries";

            choroplethMap.Area = ShapefileArea.WorldCountries;

            choroplethMap.AttributeName = "NAME";
            choroplethMap.AttributeDimension = new Dimension("Country");

            ValueMap populationMap = new ValueMap(new Measure("Population"));
            choroplethMap.Maps.Add(populationMap);

            dashboard.Items.Add(choroplethMap);
            dashboardViewer1.Dashboard = dashboard;
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the DataSource property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also