/
CustomEditForm.aspx.vb
48 lines (41 loc) · 1.78 KB
/
CustomEditForm.aspx.vb
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
Imports Microsoft.VisualBasic
Imports DevExpress.Web
Imports DevExpress.Web.Data
Imports System
Namespace WebApplication_GridTest
Partial Public Class CustomEditForm
Inherits System.Web.UI.Page
Protected Sub ASPxGridView1_Init(ByVal sender As Object, ByVal e As EventArgs)
Dim grid As ASPxGridView = CType(sender, ASPxGridView)
grid.Templates.EditForm = New CustomEditFormTemplate()
End Sub
Protected Sub ASPxGridView1_RowUpdating(ByVal sender As Object, ByVal e As ASPxDataUpdatingEventArgs)
Dim grid As ASPxGridView = CType(sender, ASPxGridView)
Dim dataType As DataType = CType(grid.GetRowValuesByKeyValue(e.Keys(0), "Type"), DataType)
Dim editorID As String = String.Empty
Select Case dataType
Case DataType.Text
editorID = "txt"
Case DataType.DateTime
editorID = "date"
Case DataType.Dictionary1
editorID = "dict"
Case DataType.Dictionary2
editorID = "dict"
End Select
Dim editor As ASPxEdit = CType(grid.FindEditFormTemplateControl(editorID), ASPxEdit)
e.NewValues("DataValue") = editor.Value.ToString()
End Sub
Protected Sub ASPxGridView1_CustomColumnDisplayText(ByVal sender As Object, ByVal e As ASPxGridViewColumnDisplayTextEventArgs)
Dim dataType As DataType = CType(e.GetFieldValue(e.VisibleRowIndex, "Type"), DataType)
If e.Column.FieldName = "DataValue" Then
Select Case dataType
Case dataType.Dictionary1
e.DisplayText = DataProvider.GetDictionaryItem(dataType, Convert.ToInt32(e.Value)).Data
Case dataType.Dictionary2
e.DisplayText = DataProvider.GetDictionaryItem(dataType, Convert.ToInt32(e.Value)).Data
End Select
End If
End Sub
End Class
End Namespace