-
Notifications
You must be signed in to change notification settings - Fork 1
/
CustomEditForm.aspx.cs
52 lines (45 loc) · 1.97 KB
/
CustomEditForm.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
47
48
49
50
51
52
using DevExpress.Web;
using DevExpress.Web.Data;
using System;
namespace WebApplication_GridTest {
public partial class CustomEditForm : System.Web.UI.Page {
protected void ASPxGridView1_Init(object sender, EventArgs e) {
ASPxGridView grid = (ASPxGridView)sender;
grid.Templates.EditForm = new CustomEditFormTemplate();
}
protected void ASPxGridView1_RowUpdating(object sender, ASPxDataUpdatingEventArgs e) {
ASPxGridView grid = (ASPxGridView)sender;
DataType dataType = (DataType)grid.GetRowValuesByKeyValue(e.Keys[0], "Type");
string editorID = string.Empty;
switch (dataType) {
case DataType.Text:
editorID = "txt";
break;
case DataType.DateTime:
editorID = "date";
break;
case DataType.Dictionary1:
editorID = "dict";
break;
case DataType.Dictionary2:
editorID = "dict";
break;
}
ASPxEdit editor = (ASPxEdit)grid.FindEditFormTemplateControl(editorID);
e.NewValues["DataValue"] = editor.Value.ToString();
}
protected void ASPxGridView1_CustomColumnDisplayText(object sender, ASPxGridViewColumnDisplayTextEventArgs e) {
DataType dataType = (DataType)e.GetFieldValue(e.VisibleRowIndex, "Type");
if (e.Column.FieldName == "DataValue") {
switch (dataType) {
case DataType.Dictionary1:
e.DisplayText = DataProvider.GetDictionaryItem(dataType, Convert.ToInt32(e.Value)).Data;
break;
case DataType.Dictionary2:
e.DisplayText = DataProvider.GetDictionaryItem(dataType, Convert.ToInt32(e.Value)).Data;
break;
}
}
}
}
}