-
Notifications
You must be signed in to change notification settings - Fork 3
/
Default.aspx.cs
46 lines (42 loc) · 1.11 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
46
using DevExpress.Utils;
using DevExpress.Web;
using System;
using System.Linq;
namespace Solution {
public partial class Default : System.Web.UI.Page {
enum DataSourceType {
Products,
Categories,
Shippers
}
protected void Page_Init(object sender, EventArgs e) {
if (!this.IsPostBack)
Session.Clear();
grid.DataBind();
}
protected void grid_DataBinding(object sender, EventArgs e) {
(sender as ASPxGridView).DataSource = GetDataSource();
}
protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
Session["selectedDataSource"] = Int32.Parse(e.Parameters);
grid.Columns.Clear();
grid.AutoGenerateColumns = true;
grid.KeyFieldName = String.Empty;
grid.DataBind();
}
private object GetDataSource() {
object o = Session["selectedDataSource"];
DataSourceType dsType = DataSourceType.Products;
if (o != null)
dsType = (DataSourceType)o;
switch (dsType) {
case DataSourceType.Categories:
return dsCategories;
case DataSourceType.Shippers:
return dsShippers;
default:
return dsProducts;
}
}
}
}