dashboard-devexpress-dot-dashboardcommon-dot-datadashboarditem.md
Gets or sets a data source to which the dashboard item is bound.
Namespace : DevExpress.DashboardCommon
Assembly : DevExpress.Dashboard.v25.2.Core.dll
NuGet Package : DevExpress.Dashboard.Core
[DefaultValue(null)]
public IDashboardDataSource DataSource { get; set; }
<DefaultValue(Nothing)>
Public Property DataSource As IDashboardDataSource
| Type | Default | Description |
|---|---|---|
| IDashboardDataSource | null |
An object implementing the IDashboardDataSource interface that specifies a data source to which the dashboard item is bound.
|
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.
The following code snippet demonstrates how to bind a Choropleth Map dashboard item to data in code.
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;
}
}
}
Imports System.Windows.Forms
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess.ConnectionParameters
Imports DevExpress.DataAccess.Sql
Namespace Dashboard_CreateChoroplethMap
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Public Sub New()
InitializeComponent()
Dim dashboard As New Dashboard()
Dim dataSource As New DashboardSqlDataSource()
Dim sqlQuery As New CustomSqlQuery("Countries", "select * from Countries")
dataSource.ConnectionParameters = New Access97ConnectionParameters("..\..\Data\countriesDB.mdb", "", "")
dataSource.Queries.Add(sqlQuery)
Dim choroplethMap As New ChoroplethMapDashboardItem()
choroplethMap.DataSource = dataSource
choroplethMap.DataMember = "Countries"
choroplethMap.Area = ShapefileArea.WorldCountries
choroplethMap.AttributeName = "NAME"
choroplethMap.AttributeDimension = New Dimension("Country")
Dim populationMap As New ValueMap(New Measure("Population"))
choroplethMap.Maps.Add(populationMap)
dashboard.Items.Add(choroplethMap)
dashboardViewer1.Dashboard = dashboard
End Sub
End Class
End Namespace
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.
e.Dashboard.DataSources.Add(ods);
foreach (var item in e.Dashboard.Items.OfType<DataDashboardItem>().Where(i => i.DataSource == query.DataSource && i.DataMember == query.Query.Name)) {
item.DataMember = "";
PieDashboardItem pies = new PieDashboardItem();
pies.DataSource = dashboard.DataSources[0];
Dimension salesPersonArgument = new Dimension("SalesPerson");
winforms-dashboard-designer-merge-dashboards-to-tabs/CS/DashboardMerger/ItemsMerger.cs#L64
DataDashboardItem dataDashboardItem = dashboardItemCopy as DataDashboardItem;
if(dataDashboardItem != null && dataDashboardItem.DataSource != null) {
string newDataSourceName = String.Empty;
pivot.DataMember = "Orders";
pivot.DataSource = dashboard.DataSources[0];
pivot.Rows.AddRange(new Dimension("ShipCountry"), new Dimension("ShipCity"));
winforms-dashboard-json-data-source/CS/DashboardJsonExample/Form1.cs#L28
PivotDashboardItem pivot = new PivotDashboardItem();
pivot.DataSource = jsonDataSource;
pivot.Rows.Add(new Dimension("ContactTitle"));
Dim pies As New PieDashboardItem()
pies.DataSource = dashboard.DataSources(0)
Dim salesPersonArgument As New Dimension("SalesPerson")
winforms-dashboard-designer-merge-dashboards-to-tabs/VB/DashboardMerger/ItemsMerger.vb#L70
Dim dataDashboardItem As DataDashboardItem = TryCast(dashboardItemCopy, DataDashboardItem)
If dataDashboardItem IsNot Nothing AndAlso dataDashboardItem.DataSource IsNot Nothing Then
Dim newDataSourceName As String = String.Empty
pivot.DataMember = "Orders"
pivot.DataSource = dashboard.DataSources(0)
pivot.Rows.AddRange(New Dimension("ShipCountry"), New Dimension("ShipCity"))
winforms-dashboard-json-data-source/VB/DashboardJsonExample/Form1.vb#L26
Dim pivot As New PivotDashboardItem()
pivot.DataSource = jsonDataSource
pivot.Rows.Add(New Dimension("ContactTitle"))
winforms-dashboard-data-federation/VB/DataFederationExample/Form1.vb#L42
pivot.DataMember = "FDS-Created-by-NodeBulder"
pivot.DataSource = federatedDS_Join
pivot.Rows.AddRange(New Dimension("CategoryName"), New Dimension("ProductName"))
See Also