Skip to content

Commit 647fd74

Browse files
DevExpressExampleBotDevExpressExampleBot
DevExpressExampleBot
authored and
DevExpressExampleBot
committed
Source auto update [skip ci]
1 parent 1f03b77 commit 647fd74

File tree

6 files changed

+350
-0
lines changed

6 files changed

+350
-0
lines changed

VB/E5045.sln

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio 2012
3+
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebSite", "WebSite\", "{E7100136-FDA4-46DF-B114-8F6ECC7C2DF8}"
4+
ProjectSection(WebsiteProperties) = preProject
5+
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
6+
Debug.AspNetCompiler.VirtualPath = "/WebSite"
7+
Debug.AspNetCompiler.PhysicalPath = "WebSite\"
8+
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\WebSite\"
9+
Debug.AspNetCompiler.Updateable = "true"
10+
Debug.AspNetCompiler.ForceOverwrite = "true"
11+
Debug.AspNetCompiler.FixedNames = "false"
12+
Debug.AspNetCompiler.Debug = "True"
13+
Release.AspNetCompiler.VirtualPath = "/WebSite"
14+
Release.AspNetCompiler.PhysicalPath = "WebSite\"
15+
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\WebSite\"
16+
Release.AspNetCompiler.Updateable = "true"
17+
Release.AspNetCompiler.ForceOverwrite = "true"
18+
Release.AspNetCompiler.FixedNames = "false"
19+
Release.AspNetCompiler.Debug = "False"
20+
VWDPort = "2101"
21+
EndProjectSection
22+
EndProject
23+
Global
24+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
25+
Debug|.NET = Debug|.NET
26+
EndGlobalSection
27+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
28+
{E7100136-FDA4-46DF-B114-8F6ECC7C2DF8}.Debug|.NET.ActiveCfg = Debug|Any CPU
29+
EndGlobalSection
30+
GlobalSection(SolutionProperties) = preSolution
31+
HideSolutionNode = FALSE
32+
EndGlobalSection
33+
EndGlobal

VB/WebSite/App_Data/nwind.mdb

1.24 MB
Binary file not shown.

VB/WebSite/Default.aspx

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
2+
3+
<%@ Register Assembly="DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
4+
Namespace="DevExpress.Web" TagPrefix="dx" %>
5+
6+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
7+
<html xmlns="http://www.w3.org/1999/xhtml">
8+
<head runat="server">
9+
<title>How to update a master grid and all its detail grids operating in Batch Edit mode simultaneously</title>
10+
<script src="UpdateLogic.js"></script>
11+
</head>
12+
<body>
13+
<form id="frmMain" runat="server">
14+
<b>How to update a master grid and all its detail grids operating in Batch Edit mode simultaneously</b>
15+
<dx:ASPxGridView ID="Grid" runat="server" KeyFieldName="CategoryID" OnCommandButtonInitialize="Grid_CommandButtonInitialize" OnCustomCallback="Grid_CustomCallback" ClientInstanceName="grid" OnBatchUpdate="Grid_BatchUpdate" AutoGenerateColumns="False" DataSourceID="nwd1">
16+
<Columns>
17+
<dx:GridViewCommandColumn ShowNewButtonInHeader="True" VisibleIndex="0" />
18+
<dx:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" VisibleIndex="1">
19+
<EditFormSettings Visible="False" />
20+
</dx:GridViewDataTextColumn>
21+
<dx:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="2">
22+
</dx:GridViewDataTextColumn>
23+
<dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="3">
24+
</dx:GridViewDataTextColumn>
25+
</Columns>
26+
<ClientSideEvents DetailRowExpanding="OnExpanding" DetailRowCollapsing="OnCollapsing" EndCallback="OnEndCallback" CallbackError="OnCallbackError" BatchEditConfirmShowing="OnConfirm" />
27+
<SettingsDetail ShowDetailButtons="true" ShowDetailRow="true" />
28+
<Templates>
29+
<DetailRow>
30+
<dx:ASPxGridView runat="server" OnCommandButtonInitialize="Grid_CommandButtonInitialize" KeyFieldName="ProductID" OnBatchUpdate="grid_BatchUpdate" OnBeforePerformDataSelect="grid2_BeforePerformDataSelect" ID="grid2" AutoGenerateColumns="False" DataSourceID="nwd2">
31+
<Columns>
32+
<dx:GridViewCommandColumn ShowNewButtonInHeader="true" ShowDeleteButton="True" VisibleIndex="0" />
33+
<dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="1">
34+
<EditFormSettings Visible="False" />
35+
</dx:GridViewDataTextColumn>
36+
<dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="2">
37+
</dx:GridViewDataTextColumn>
38+
<dx:GridViewDataCheckColumn FieldName="Discontinued" VisibleIndex="4" />
39+
</Columns>
40+
<ClientSideEvents BatchEditConfirmShowing="OnConfirm" />
41+
<SettingsEditing Mode="Batch" />
42+
</dx:ASPxGridView>
43+
</DetailRow>
44+
<StatusBar>
45+
<div style="text-align: right">
46+
<dx:ASPxButton ID="btn" Text="Save Changes" RenderMode="Link" AutoPostBack="false" runat="server">
47+
<ClientSideEvents Click="OnClick" />
48+
</dx:ASPxButton>
49+
<dx:ASPxButton ID="btn2" Text="Cancel Changes" RenderMode="Link" AutoPostBack="false" runat="server">
50+
<ClientSideEvents Click="OnCancel" />
51+
</dx:ASPxButton>
52+
</div>
53+
</StatusBar>
54+
</Templates>
55+
<SettingsEditing Mode="Batch" />
56+
</dx:ASPxGridView>
57+
<asp:AccessDataSource ID="nwd1" runat="server" DataFile="~/App_Data/nwind.mdb" DeleteCommand="DELETE FROM [Categories] WHERE [CategoryID] = ?" InsertCommand="INSERT INTO [Categories] ([CategoryName], [Description]) VALUES (?, ?)" SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]" UpdateCommand="UPDATE [Categories] SET [CategoryName] = ?, [Description] = ? WHERE [CategoryID] = ?">
58+
<DeleteParameters>
59+
<asp:Parameter Name="CategoryID" Type="Int32" />
60+
</DeleteParameters>
61+
<InsertParameters>
62+
<asp:Parameter Name="CategoryName" Type="String" />
63+
<asp:Parameter Name="Description" Type="String" />
64+
</InsertParameters>
65+
<UpdateParameters>
66+
<asp:Parameter Name="CategoryName" Type="String" />
67+
<asp:Parameter Name="Description" Type="String" />
68+
<asp:Parameter Name="CategoryID" Type="Int32" />
69+
</UpdateParameters>
70+
</asp:AccessDataSource>
71+
<asp:AccessDataSource ID="nwd2" runat="server" DataFile="~/App_Data/nwind.mdb" DeleteCommand="DELETE FROM [Products] WHERE [ProductID] = ?" InsertCommand="INSERT INTO [Products] ([ProductName], [CategoryID], [Discontinued]) VALUES (?, ?, ?)" SelectCommand="SELECT [ProductID], [ProductName], [CategoryID] , [Discontinued] FROM [Products] WHERE ([CategoryID] = ?)" UpdateCommand="UPDATE [Products] SET [ProductName] = ?, [Discontinued] = ? WHERE [ProductID] = ?">
72+
<DeleteParameters>
73+
<asp:Parameter Name="ProductID" Type="Int32" />
74+
</DeleteParameters>
75+
<InsertParameters>
76+
<asp:Parameter Name="ProductName" Type="String" />
77+
<asp:Parameter Name="CategoryID" Type="Int32" />
78+
<asp:Parameter Name="Discontinued" Type="Boolean" />
79+
</InsertParameters>
80+
<SelectParameters>
81+
<asp:SessionParameter DefaultValue="?" Name="CategoryID" SessionField="Category" Type="Int32" />
82+
</SelectParameters>
83+
<UpdateParameters>
84+
<asp:Parameter Name="ProductName" Type="String" />
85+
<asp:Parameter Name="Discontinued" Type="Boolean" />
86+
<asp:Parameter Name="ProductID" Type="Int32" />
87+
</UpdateParameters>
88+
</asp:AccessDataSource>
89+
<dx:ASPxLabel runat="server" ForeColor="Red" Font-Size="Large" Font-Bold="true" Text="" ID="lbl" ClientInstanceName="lbl"></dx:ASPxLabel>
90+
</form>
91+
</body>
92+
</html>

VB/WebSite/Default.aspx.vb

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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

VB/WebSite/UpdateLogic.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
var visibleIndicies = [];
2+
var errorMessage = "";
3+
var buttonFlag = false;
4+
function OnClick(s, e) {
5+
if (visibleIndicies.length == 0)
6+
grid.UpdateEdit();
7+
else {
8+
buttonFlag = true;
9+
grid.PerformCallback(visibleIndicies);
10+
}
11+
}
12+
function OnCancel(s, e) {
13+
for (var i = 0; i < visibleIndicies.length; i++) {
14+
var currentKey = grid.GetRowKey(visibleIndicies[i]);
15+
var childgrid = ASPxClientControl.GetControlCollection().GetByName("detailGrid" + currentKey);
16+
if (childgrid != undefined && childgrid != null) {
17+
childgrid.CancelEdit();
18+
}
19+
}
20+
grid.CancelEdit();
21+
}
22+
function OnConfirm(s, e) {
23+
if (e.requestTriggerID == 'Grid' && buttonFlag) {
24+
e.cancel = true;
25+
}
26+
}
27+
function AddCurrentDetailGrid(visibleIndex) {
28+
if (visibleIndicies.indexOf(visibleIndex) == -1)
29+
visibleIndicies.push(visibleIndex);
30+
}
31+
function RemoveCurrentDetailGrid(visibleIndex) {
32+
var arrayIndex = visibleIndicies.indexOf(visibleIndex);
33+
if (arrayIndex > -1)
34+
visibleIndicies.splice(arrayIndex, 1);
35+
}
36+
function OnExpanding(s, e) {
37+
AddCurrentDetailGrid(e.visibleIndex);
38+
}
39+
function OnCollapsing(s, e) {
40+
RemoveCurrentDetailGrid(e.visibleIndex);
41+
}
42+
function OnEndCallback(s, e) {
43+
if (buttonFlag)
44+
buttonFlag = false;
45+
if (errorMessage != "") {
46+
lbl.SetText(errorMessage);
47+
errorMessage = "";
48+
}
49+
else
50+
lbl.SetText("");
51+
}
52+
function OnCallbackError(s, e) {
53+
errorMessage = e.message;
54+
e.handled = true;
55+
}

VB/WebSite/web.config

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
For more information on how to configure your ASP.NET application, please visit
4+
http://go.microsoft.com/fwlink/?LinkId=169433
5+
-->
6+
<configuration>
7+
<configSections>
8+
<sectionGroup name="devExpress">
9+
<section name="themes" type="DevExpress.Web.ThemesConfigurationSection, DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
10+
<section name="compression" type="DevExpress.Web.CompressionConfigurationSection, DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
11+
<section name="settings" type="DevExpress.Web.SettingsConfigurationSection, DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
12+
<section name="errors" type="DevExpress.Web.ErrorsConfigurationSection, DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
13+
</sectionGroup>
14+
</configSections>
15+
<system.web>
16+
<compilation debug="true" targetFramework="4.0">
17+
<assemblies>
18+
<add assembly="DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
19+
<add assembly="DevExpress.Data.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
20+
<add assembly="DevExpress.Printing.v14.1.Core, Version=14.1.15.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
21+
<add assembly="DevExpress.Web.ASPxThemes.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
22+
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
23+
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
24+
<add assembly="DevExpress.RichEdit.v14.1.Core, Version=14.1.15.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
25+
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
26+
</assemblies>
27+
</compilation>
28+
<httpModules>
29+
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
30+
</httpModules>
31+
<httpHandlers>
32+
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="DX.ashx" validate="false" />
33+
<add verb="GET,POST" path="ASPxUploadProgressHandlerPage.ashx" type="DevExpress.Web.ASPxUploadProgressHttpHandler, DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
34+
</httpHandlers>
35+
</system.web>
36+
<system.webServer>
37+
<modules>
38+
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
39+
</modules>
40+
<validation validateIntegratedModeConfiguration="false" />
41+
<handlers>
42+
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="DX.ashx" name="ASPxHttpHandlerModule" preCondition="integratedMode" />
43+
<add name="ASPxUploadProgressHandler" preCondition="integratedMode" verb="GET,POST" path="ASPxUploadProgressHandlerPage.ashx" type="DevExpress.Web.ASPxUploadProgressHttpHandler, DevExpress.Web.v14.1, Version=14.1.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
44+
</handlers>
45+
</system.webServer>
46+
<devExpress>
47+
<themes enableThemesAssembly="true" styleSheetTheme="" theme="" customThemeAssemblies="" />
48+
<compression enableHtmlCompression="false" enableCallbackCompression="true" enableResourceCompression="true" enableResourceMerging="true" />
49+
<settings doctypeMode="Xhtml" rightToLeft="false" embedRequiredClientLibraries="false" />
50+
<errors callbackErrorRedirectUrl="" />
51+
</devExpress>
52+
</configuration>

0 commit comments

Comments
 (0)