How to: Bind a Dashboard to a DataSet at Design Time and Provide Data at Runtime

Note

Starting with v17.1, we recommend using the ASPxDashboard control or a corresponding ASP.NET MVC extension to display dashboards within web applications. Refer to the following KB articles to learn more about migration to ASPxDashboard / ASP.NET MVC Dashboard:

The following tutorial shows how to create the data source by specifying a schema using an XML/XSD file or a data class at Visual Studio design time.

  1. To create a new data source, click the Add button in the Data Sources dialog and select XML Schema.

    DataSourceWizard_FirstPageVS

    Click Next.

  2. On the next page, locate the XML/XSD file or specify a data class to provide a data source schema. Click Finish.

    DataSourceWizardVS_ProvideSchemaPage

  3. The invoked Data Sources dialog will contain the created data source.

    DataSourcesDialog_NewXMLSchema

  4. Type the required DataMember manually to retrieve the data source fields...

    DataSourcesDialog_SpecifyDataMember

    ... and click OK to add the created data source to the collection of dashboard data sources.

  5. Finally, to provide actual data for the created data source, create a data source object instance in code and assign it to the ObjectDataSource.DataSource property of the DashboardObjectDataSource object or handle the Dashboard.DataLoading event to provide data at runtime.

The following example demonstrates how to bind a dashboard to a DataSet at design time and fill it with data from the SalesPerson table in the Northwind database.

In this example, the dashboard is created at design time within Visual Studio and displayed in the ASPxDashboardViewer. The dataset is filled with data in the Dashboard.DataLoading event handler.

<%@ Page Language="vb" AutoEventWireup="true" 
                       CodeBehind="WebForm1.aspx.vb" 
                       Inherits="Dashboard_DataLoading.WebForm1" %>

<%@ Register Assembly="DevExpress.Dashboard.v15.1.Web, Version=15.1.7.0, 
                       Culture=neutral, 
                       PublicKeyToken=b88d1754d700e49a"
             Namespace="DevExpress.DashboardWeb" TagPrefix="dx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <dx:ASPxDashboardViewer ID="ASPxDashboardViewer1" runat="server" FullscreenMode=true
            DashboardSource="<%#GetType(Dashboard_DataLoading.Dashboard1)%>">
        </dx:ASPxDashboardViewer>
    </div>
    </form>
</body>
</html>
See Also