1
+ Imports System
2
+ Imports System.Collections.Generic
3
+ Imports System.Collections.Specialized
4
+ Imports System.ComponentModel
5
+ Imports System.Linq
6
+ Imports DevExpress.Web.Data
7
+ Imports DevExpress.Web
8
+ Imports System.Data
9
+ Imports System.Web.UI
10
+ Imports System.Web.UI.WebControls
11
+
12
+ Partial Public Class _Default
13
+ Inherits System.Web.UI.Page
14
+
15
+ Protected Sub Grid_BatchUpdate( ByVal sender As Object , ByVal e As ASPxDataBatchUpdateEventArgs)
16
+ For Each args In e.InsertValues
17
+ InsertNewItem(args.NewValues, True , DirectCast (sender, ASPxGridView))
18
+ Next args
19
+ For Each args In e.UpdateValues
20
+ UpdateItem(args.Keys, args.NewValues, True )
21
+ Next args
22
+ For Each args In e.DeleteValues
23
+ DeleteItem(args.Keys, args.Values, True )
24
+ Next args
25
+ e.Handled = True
26
+ End Sub
27
+ Protected Sub InsertNewItem( ByVal newValues As OrderedDictionary, ByVal isParent As Boolean , ByVal currentGrid As ASPxGridView)
28
+ 'comment the bellow line to check data modifications
29
+ Throw New NotImplementedException( "Data modifications aren't allowed in online example" )
30
+ If isParent Then
31
+ Insert(newValues,nwd1)
32
+ Else
33
+ nwd2.InsertParameters( "CategoryID" ).DefaultValue = currentGrid.GetMasterRowKeyValue().ToString()
34
+ Insert(newValues, nwd2)
35
+ End If
36
+
37
+ End Sub
38
+ Private Sub Insert( ByVal newValues As OrderedDictionary, ByVal datasource As AccessDataSource)
39
+ For Each item In newValues.Keys
40
+ datasource.InsertParameters( CStr (item)).DefaultValue = Convert.ToString(newValues(item))
41
+ Next item
42
+ datasource.Insert()
43
+ End Sub
44
+ Protected Sub UpdateItem( ByVal keys As OrderedDictionary, ByVal newValues As OrderedDictionary, ByVal isParent As Boolean )
45
+ 'comment the bellow line to check data modifications
46
+ Throw New NotImplementedException( "Data modifications aren't allowed in online example" )
47
+ If isParent Then
48
+ Update(keys, newValues, nwd1)
49
+ Else
50
+ Update(keys, newValues, nwd2)
51
+ End If
52
+ End Sub
53
+
54
+ Private Sub Update( ByVal keys As OrderedDictionary, ByVal newValues As OrderedDictionary, ByVal datasource As AccessDataSource)
55
+ For Each item In newValues.Keys
56
+ datasource.UpdateParameters( CStr (item)).DefaultValue = Convert.ToString(newValues(item))
57
+ Next item
58
+ datasource.UpdateParameters(nwd2.UpdateParameters.Count - 1 ).DefaultValue = Convert.ToString(keys( 0 ))
59
+ datasource.Update()
60
+ End Sub
61
+ Protected Sub DeleteItem( ByVal keys As OrderedDictionary, ByVal values As OrderedDictionary, ByVal isParent As Boolean )
62
+ 'comment the bellow line to check data modifications
63
+ Throw New NotImplementedException( "Data modifications aren't allowed in online example" )
64
+ If isParent Then
65
+ nwd1.DeleteParameters( 0 ).DefaultValue = Convert.ToString(keys( "CategoryID" ))
66
+ nwd1.Delete()
67
+ Else
68
+ nwd2.DeleteParameters( 0 ).DefaultValue = Convert.ToString(keys( "ProductID" ))
69
+ nwd2.Delete()
70
+ End If
71
+
72
+ End Sub
73
+
74
+ Protected Sub grid2_BeforePerformDataSelect( ByVal sender As Object , ByVal e As EventArgs)
75
+ Dim child As ASPxGridView = TryCast (sender, ASPxGridView)
76
+ Dim container As GridViewDetailRowTemplateContainer = TryCast (child.NamingContainer, GridViewDetailRowTemplateContainer)
77
+ child.ClientInstanceName = "detailGrid" & container.KeyValue
78
+ Session( "Category" ) = child.GetMasterRowKeyValue()
79
+
80
+ End Sub
81
+ Protected Sub Grid_CustomCallback( ByVal sender As Object , ByVal e As ASPxGridViewCustomCallbackEventArgs)
82
+ Dim parentGrid As ASPxGridView = TryCast (sender, ASPxGridView)
83
+ parentGrid.UpdateEdit()
84
+ parentGrid.DataBind()
85
+ If String .IsNullOrEmpty(e.Parameters) Then
86
+ Return
87
+ End If
88
+ Dim [paramArray]() As String = e.Parameters.Split( ","c )
89
+ For i As Integer = 0 To [paramArray].Length - 1
90
+ If String .IsNullOrWhiteSpace([paramArray](i)) Then
91
+ Continue For
92
+ End If
93
+ Dim child As ASPxGridView = TryCast (parentGrid.FindDetailRowTemplateControl(Convert.ToInt32([paramArray](i)), "grid2" ), ASPxGridView)
94
+ If child IsNot Nothing Then
95
+ child.UpdateEdit()
96
+ child.DataBind()
97
+ End If
98
+ Next i
99
+ End Sub
100
+ 'INSTANT VB NOTE: The method grid_BatchUpdate was renamed since Visual Basic does not allow same-signature methods with the same name:
101
+ Protected Sub grid_BatchUpdate_Conflict( ByVal sender As Object , ByVal e As ASPxDataBatchUpdateEventArgs)
102
+ For Each args In e.InsertValues
103
+ InsertNewItem(args.NewValues, False , DirectCast (sender, ASPxGridView))
104
+ Next args
105
+ For Each args In e.UpdateValues
106
+ UpdateItem(args.Keys, args.NewValues, False )
107
+ Next args
108
+ For Each args In e.DeleteValues
109
+ DeleteItem(args.Keys, args.Values, False )
110
+ Next args
111
+ e.Handled = True
112
+ End Sub
113
+ Protected Sub Grid_CommandButtonInitialize( ByVal sender As Object , ByVal e As ASPxGridViewCommandButtonEventArgs)
114
+ If e.ButtonType = ColumnCommandButtonType.Update OrElse e.ButtonType = ColumnCommandButtonType.Cancel Then
115
+ e.Visible = False
116
+ End If
117
+ End Sub
118
+ End Class
0 commit comments