Back to Devexpress

DataLoadingEventArgs.DataId Property

dashboard-devexpress-dot-dashboardcommon-dot-dataloadingeventargs-9d925c31.md

latest9.1 KB
Original Source

DataLoadingEventArgs.DataId Property

Gets an object data source’s unique identifier.

Namespace : DevExpress.DashboardCommon

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

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public string DataId { get; }
vb
Public ReadOnly Property DataId As String

Property Value

TypeDescription
String

An object data source’s identifier.

|

Remarks

Use the DataId property to identify the data source for which the event is raised.

This example shows how to bind the ASP.NET MVC Dashboard extension to the Object Data Source and use the DashboardConfigurator.DataLoading event to supply the data source with data:

csharp
using System.Web.Routing;
using DevExpress.DashboardWeb;
using DevExpress.DashboardWeb.Mvc;
using DevExpress.DashboardCommon;

namespace DashboardMVC {
    public static class DashboardConfig {
        public static void RegisterService(RouteCollection routes) {
            routes.MapDashboardRoute("dashboardControl");

            DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");
            DashboardConfigurator.Default.SetDashboardStorage(dashboardFileStorage);
            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
             // Registers an Object data source.
            DashboardObjectDataSource objDataSource = new DashboardObjectDataSource("Object Data Source");
            objDataSource.DataId = "Object Data Source ID";
            dataSourceStorage.RegisterDataSource("objDataSource", objDataSource.SaveToXml());
            DashboardConfigurator.Default.SetDataSourceStorage(dataSourceStorage);
            DashboardConfigurator.Default.DataLoading += DataLoading;
        }
         private static void DataLoading(object sender, DataLoadingWebEventArgs e) {
            if(e.DataId == "Object Data Source ID") {
                e.Data = Invoices.CreateData();
            }
        }
    }
}
vb
Imports System.Web.Routing
Imports DevExpress.DashboardWeb
Imports DevExpress.DashboardWeb.Mvc
Imports DevExpress.DashboardCommon

Namespace DashboardMVC
    Public Module DashboardConfig
        Public Sub RegisterService(ByVal routes As RouteCollection)
            routes.MapDashboardRoute("dashboardControl")

            Dim dashboardFileStorage As New DashboardFileStorage("~/App_Data/Dashboards")
            DashboardConfigurator.Default.SetDashboardStorage(dashboardFileStorage)
             Dim dataSourceStorage As New DataSourceInMemoryStorage()
             ' Registers an Object data source.
            Dim objDataSource As New DashboardObjectDataSource("Object Data Source")
            objDataSource.DataId = "Object Data Source ID"
            dataSourceStorage.RegisterDataSource("objDataSource", objDataSource.SaveToXml())
            DashboardConfigurator.Default.SetDataSourceStorage(dataSourceStorage)
            AddHandler DashboardConfigurator.Default.DataLoading, AddressOf DataLoading
        End Sub
         Private Sub DataLoading(ByVal sender As Object, ByVal e As DataLoadingWebEventArgs)
            If e.DataId = "Object Data Source ID" Then
                e.Data = Invoices.CreateData()
            End If
         End Sub
    End Module
End Namespace

The following code snippets (auto-collected from DevExpress Examples) contain references to the DataId 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.

winforms-dashboard-window-function-calc-field/CS/DesignerForm1.cs#L16

csharp
private void DashboardDesigner1_DataLoading(object sender, DataLoadingEventArgs e) {
    if (e.DataId == "odsSales") {
        e.Data = ProductSales.GetProductSales();

asp-net-core-dashboard-custom-item-gallery/CS/AspNetCoreCustomItem/Startup.cs#L80

csharp
private void Configurator_DataLoading(object sender, DataLoadingWebEventArgs e) {
    if (e.DataId == "odsTaskData") {
        DataSet dataSet = new DataSet();

DashboardDifferentUserDataAspNetCore/CS/Code/MultiTenantDashboardConfigurator.cs#L41

csharp
if (e.DataId == "odsSales") {
    if (userName == "Admin") {

dashboard-blazor-webassembly-localization/CS/BlazorDashboardApp/BlazorDashboardApp.Server/Code/DashboardUtils.cs#L18

csharp
configurator.DataLoading += (s, e) => {
    if (e.DataId == "employees") {
        e.Data = Employee.Employees;

dashboard-blazor-server-localization/CS/BlazorDashboardApp/Code/DashboardUtils.cs#L17

csharp
configurator.DataLoading += (s, e) => {
    if (e.DataId == "employees") {
        e.Data = Employee.Employees;

winforms-dashboard-window-function-calc-field/VB/DesignerForm1.vb#L18

vb
Private Sub DashboardDesigner1_DataLoading(ByVal sender As Object, ByVal e As DataLoadingEventArgs) Handles dashboardDesigner.DataLoading
    If e.DataId = "odsSales" Then
        e.Data = ProductSales.GetProductSales()

web-forms-dashboard-save-dashboards-title-as-file-name/VB/DXWebApplication2/Default.aspx.vb#L37

vb
Protected Sub DataLoading(ByVal sender As Object, ByVal e As DataLoadingWebEventArgs)
    If Equals(e.DataId, "Object Data Source Data Id") Then
        e.Data = Invoices.CreateData()

aspnet-mvc-dashboard-data-federation/VB/MVC_DataFederationExample/App_Start/DashboardConfig.vb#L70

vb
Private Shared Sub DataLoading(ByVal sender As Object, ByVal e As DataLoadingWebEventArgs)
    If e.DataId = "odsInvoices" Then
        e.Data = Invoices.CreateData()

asp-net-web-forms-dashboard-register-data-sources/VB/WebFormsDashboardDataSources/Pages/ObjectDashboard.aspx.vb#L28

vb
Private Sub ASPxDashboardObjectDS_DataLoading(ByVal sender As Object, ByVal e As DataLoadingWebEventArgs)
    If Equals(e.DataId, "objectDataSource") Then
        e.Data = Invoices.CreateData()

asp-net-mvc-dashboard-register-data-sources/VB/MvcDashboardDataSources/Configuration/ObjectDataSourceConfigurator.vb#L16

vb
Private Shared Sub DataLoading(ByVal sender As Object, ByVal e As DataLoadingWebEventArgs)
    If e.DataId = "objectDataSource" Then
        e.Data = Invoices.CreateData()

See Also

DataLoadingEventArgs Class

DataLoadingEventArgs Members

DevExpress.DashboardCommon Namespace