using DevExpress.DashboardCommon;
using System.Collections.Generic;
using System.Data;
namespace DXWebApplication5 {
public class CustomObjectDataSourceCustomFillService : IObjectDataSourceCustomFillService {
public object GetData(DashboardObjectDataSource dataSource, ObjectDataSourceFillParameters fillParameters) {
if (fillParameters.DataFields == null || fillParameters.DataFields.Length == 0) {
return null;
}
List<SalesPersonData> data = DataGenerator.CreateSourceData();
DataTable table = new DataTable();
foreach (string field in fillParameters.DataFields) {
table.Columns.Add(field);
}
for (int i = 0; i < data.Count; i++) {
object[] row = new object[fillParameters.DataFields.Length];
for (int j = 0; j < fillParameters.DataFields.Length; j++) {
row[j] = GetPropertyValue(data[i], fillParameters.DataFields[j]);
}
table.Rows.Add(row);
}
return table.DefaultView;
}
object GetPropertyValue(SalesPersonData obj, string propName) {
return propName == "SalesPerson" ? (object)obj.SalesPerson : (object)obj.Quantity;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace DXWebApplication5 {
public class SalesPersonData {
public string SalesPerson { get; set; }
public int Quantity { get; set; }
}
public static class DataGenerator {
public static List<SalesPersonData> CreateSourceData() {
List<SalesPersonData> data = new List<SalesPersonData>();
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++) {
SalesPersonData record = new SalesPersonData();
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);
}
return data;
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DXWebApplication5.Default1" %>
<%@ Register Assembly="DevExpress.Dashboard.v18.2.Web.WebForms, Version=18.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.DashboardWeb" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="position: absolute;top: 0;left: 0; bottom: 0;right: 0;overflow: hidden;">
<dx:ASPxDashboard ID="ASPxDashboard1" runat="server" Width="100%" Height="100%" UseNeutralFilterMode="true">
</dx:ASPxDashboard>
</div>
</form>
</body>
</html>
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using System;
namespace DXWebApplication5 {
public partial class Default1 : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");
ASPxDashboard1.SetDashboardStorage(dashboardFileStorage);
DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
DashboardObjectDataSource objDataSource = new DashboardObjectDataSource("Object Data Source", typeof(SalesPersonData));
dataSourceStorage.RegisterDataSource("objDataSource", objDataSource.SaveToXml());
ASPxDashboard1.SetDataSourceStorage(dataSourceStorage);
ASPxDashboard1.ServiceContainer.AddService(typeof(IObjectDataSourceCustomFillService), new CustomObjectDataSourceCustomFillService());
}
}
}
Imports DevExpress.DashboardCommon
Imports System.Collections.Generic
Imports System.Data
Namespace DXWebApplication5
Public Class CustomObjectDataSourceCustomFillService
Implements IObjectDataSourceCustomFillService
Public Function GetData(ByVal dataSource As DashboardObjectDataSource, ByVal fillParameters As ObjectDataSourceFillParameters) As Object
If fillParameters.DataFields Is Nothing OrElse fillParameters.DataFields.Length = 0 Then
Return Nothing
End If
Dim data As List(Of SalesPersonData) = DataGenerator.CreateSourceData()
Dim table As New DataTable()
For Each field As String In fillParameters.DataFields
table.Columns.Add(field)
Next field
For i As Integer = 0 To data.Count - 1
Dim row(fillParameters.DataFields.Length - 1) As Object
For j As Integer = 0 To fillParameters.DataFields.Length - 1
row(j) = GetPropertyValue(data(i), fillParameters.DataFields(j))
Next j
table.Rows.Add(row)
Next i
Return table.DefaultView
End Function
Private Function GetPropertyValue(ByVal obj As SalesPersonData, ByVal propName As String) As Object
Return If(propName = "SalesPerson", DirectCast(obj.SalesPerson, Object), DirectCast(obj.Quantity, Object))
End Function
End Class
End Namespace
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Namespace DXWebApplication5
Public Class SalesPersonData
Public Property SalesPerson() As String
Public Property Quantity() As Integer
End Class
Public NotInheritable Class DataGenerator
Private Sub New()
End Sub
Public Shared Function CreateSourceData() As List(Of SalesPersonData)
Dim data As New List(Of SalesPersonData)()
Dim salesPersons() As String = { "Andrew Fuller", "Michael Suyama", "Robert King", "Nancy Davolio", "Margaret Peacock", "Laura Callahan", "Steven Buchanan", "Janet Leverling" }
For i As Integer = 0 To 99
Dim record As New SalesPersonData()
Dim seed As Integer = CInt(Date.Now.Ticks) And &HFFFF
record.SalesPerson = salesPersons((New Random(seed)).Next(0, salesPersons.Length))
record.Quantity = (New Random(seed)).Next(0, 100)
data.Add(record)
Next i
Return data
End Function
End Class
End Namespace
<%@ Page Language="vb" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="DXWebApplication5.Default1" %>
<%@ Register Assembly="DevExpress.Dashboard.v18.2.Web.WebForms, Version=18.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.DashboardWeb" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="position: absolute;top: 0;left: 0; bottom: 0;right: 0;overflow: hidden;">
<dx:ASPxDashboard ID="ASPxDashboard1" runat="server" Width="100%" Height="100%" UseNeutralFilterMode="true">
</dx:ASPxDashboard>
</div>
</form>
</body>
</html>
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardWeb
Imports System
Namespace DXWebApplication5
Partial Public Class Default1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim dashboardFileStorage As New DashboardFileStorage("~/App_Data/Dashboards")
ASPxDashboard1.SetDashboardStorage(dashboardFileStorage)
Dim dataSourceStorage As New DataSourceInMemoryStorage()
Dim objDataSource As New DashboardObjectDataSource("Object Data Source", GetType(SalesPersonData))
dataSourceStorage.RegisterDataSource("objDataSource", objDataSource.SaveToXml())
ASPxDashboard1.SetDataSourceStorage(dataSourceStorage)
ASPxDashboard1.ServiceContainer.AddService(GetType(IObjectDataSourceCustomFillService), New CustomObjectDataSourceCustomFillService())
End Sub
End Class
End Namespace