How to: Bind a Dashboard to a List Object

To learn how to bind a dashboard to the Object data source using the Dashboard Designer, see Binding to Object Data Sources.

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

In this example, information about the sold units quantity is provided at runtime. The dashboard data source is added to the Dashboard.DataSources collection on the first load.

To update the displayed data, the DashboardViewer.ReloadData method is called. This raises the DashboardViewer.DataLoading event and allows supplying the dashboard with updated data.

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);
            return data;
See Also