-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDefault.aspx.cs
45 lines (36 loc) · 1.81 KB
/
Default.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxPivotGrid;
using DevExpress.XtraPivotGrid;
using System.Linq;
namespace ASPxPivotGrid_RuntimeDataBinding {
public partial class _Default : Page {
//private AccessDataSource ds;
private SqlDataSource ds;
private ASPxPivotGrid ASPxPivotGrid1;
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
// Initializes a data source.
ds = new SqlDataSource("System.Data.OleDb","Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\nwind.mdb",
"SELECT [CategoryName], [ProductName], [ProductSales], [ShippedDate] FROM [ProductReports]");
// Initializes ASPxPivotGrid.
ASPxPivotGrid1 = new ASPxPivotGrid();
ASPxPivotGrid1.OptionsData.DataProcessingEngine = PivotDataProcessingEngine.Optimized;
// Binds ASPxPivotGrid to the data source.
ASPxPivotGrid1.DataSource = ds;
// Places the Pivot Grid onto a page.
form1.Controls.Add(ASPxPivotGrid1);
if (ASPxPivotGrid1.Fields.Count != 0)
return;
// Creates Pivot Grid fields for all data source columns.
ASPxPivotGrid1.RetrieveFields();
// Locates the Pivot Grid fields in appropriate areas.
ASPxPivotGrid1.Fields["CategoryName"].Area = PivotArea.RowArea;
ASPxPivotGrid1.Fields["ProductName"].Area = PivotArea.RowArea;
ASPxPivotGrid1.Fields["ShippedDate"].Area = PivotArea.ColumnArea;
ASPxPivotGrid1.Fields["ProductSales"].Area = PivotArea.DataArea;
(ASPxPivotGrid1.Fields["ShippedDate"].DataBinding as DataSourceColumnBinding).GroupInterval = PivotGroupInterval.DateYear;
}
}
}