Skip to main content

Dashboard.AddDataSource(String, Object) Method

OBSOLETE

The Dashboard.AddDataSource method is obsolete now. Use the Dashboard.DataSources.Add method instead.

Adds a data source bound to the specified data and with the specified name to the Dashboard.DataSources collection.

Namespace: DevExpress.DashboardCommon

Assembly: DevExpress.Dashboard.v24.2.Core.dll

Declaration

[Obsolete("The Dashboard.AddDataSource method is obsolete now. Use the Dashboard.DataSources.Add method instead.")]
public void AddDataSource(
    string name,
    object data
)

Parameters

Name Type Description
name String

A String that specifies the data source name.

data Object

An object that contains data for the data source.

Remarks

An object passed as the data parameter should implement the IEnumerable or IListSource interface.

To learn more, see Object Data Source.

Example

The following example demonstrates how to bind a dashboard to a List object.

The quantity values are provided at runtime. The dashboard data source is added to the Dashboard.DataSources collection on the first load.

Click the Reload Data button to call the DashboardViewer.ReloadData method. It raises the DashboardViewer.DataLoading event and supplies the dashboard with updated data.

win-dashboard-bind-to-list-object

View Example: How to Bind a Dashboard to a List of Objects

using System;
using System.Collections.Generic;
using System.Threading;

namespace Dashboard_BindingToList {
    public class Data {
        public string SalesPerson { get; set; }
        public int Quantity { get; set; }

        public static List<Data> CreateData() {
            List<Data> data = new List<Data>();
            string[] salesPersons = { "Andrew Fuller", "Michael Suyama", "Robert King", "Nancy Davolio",
                "Margaret Peacock", "Laura Callahan", "Steven Buchanan", "Janet Leverling" };

            for (int i = 0; i < 100; i++) {
                Data record = new Data();
                int seed = (int)DateTime.Now.Ticks & 0x0000FFFF;
                record.SalesPerson = salesPersons[new Random(seed).Next(0, salesPersons.Length)];
                record.Quantity = new Random(seed).Next(0, 100);
                data.Add(record);
                Thread.Sleep(3);
            }
            return data;
        }
    }
}
See Also