Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 37 additions & 16 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
<!-- default badges list -->
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/128534636/19.2.6%2B)
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T356740)
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
<!-- default badges end -->
<!-- default file list -->
*Files to look at*:

* [DataProvider.cs](./CS/App_Code/DataProvider.cs) (VB: [DataProvider.vb](./VB/App_Code/DataProvider.vb))
* [Default.aspx](./CS/Default.aspx) (VB: [Default.aspx](./VB/Default.aspx))
* [Default.aspx.cs](./CS/Default.aspx.cs) (VB: [Default.aspx.vb](./VB/Default.aspx.vb))
* [JavaScript.js](./CS/JavaScript.js) (VB: [JavaScript.js](./VB/JavaScript.js))
<!-- default file list end -->
# ASPxGridView - How to implement cascading combo boxes in Batch Edit mode by using WebMethods
# Grid View for ASP.NET Web Forms - How to use WebMethods to implement cascading combo boxes in batch edit mode
<!-- run online -->
**[[Run Online]](https://codecentral.devexpress.com/t356740/)**
<!-- run online end -->

This example demonstrates how to implement cascading combo box editors in batch mode and use **WebMethods** to populate the editors with data. This example combines the following approaches:

* [Grid View for ASP.NET Web Forms - Cascading Combo Boxes in Batch Edit Mode](https://github.com/DevExpress-Examples/asp-net-web-forms-grid-cascading-comboboxes-in-batch-edit-mode)
* [Combo Box for ASP.NET Web Forms - How to use the WebMethod attribute to populate a cascading editor with data](https://github.com/DevExpress-Examples/how-to-populate-a-cascading-aspxcombobox-by-using-webmethods-t356687)

![Use WebMethods to implement cascading combo boxes in batch mode](WebMethodsInGrid.png)

## Overview

The main idea is to use [WebMethods](https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008/byxd99hx(v=vs.90)?redirectedfrom=MSDN) to update the secondary editor's data based on the primary editor's value.

<p>This example shows how to implement cascading combo boxes in <a href="https://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewEditingSettings_Modetopic">EditingSettings</a> "Batch" mode by using <a href="https://msdn.microsoft.com/en-us/library/byxd99hx(v=vs.90).aspx">WebMethods</a>. The example is based on <a href="https://www.devexpress.com/Support/Center/p/T124512">ASPxGridView - How to implement cascading comboboxes in Batch Edit mode</a> and <a href="https://www.devexpress.com/Support/Center/p/T356687">How to populate a cascading ASPxComboBox by using WebMethods</a> examples. The main idea is to remove EditTemplate from <a href="https://documentation.devexpress.com/#AspNet/clsDevExpressWebASPxGridViewtopic">ASPxGridView</a> and replace the <a href="https://documentation.devexpress.com/#AspNet/clsDevExpressWebASPxComboBoxtopic">ASPxComboBox</a> <a href="https://documentation.devexpress.com/#AspNet/DevExpressWebASPxAutoCompleteBoxBase_Callbacktopic">Callback</a> by <a href="https://msdn.microsoft.com/en-us/library/byxd99hx(v=vs.90).aspx">WebMethods</a> to refresh the child's combo box item collection. This will improve the server's response time and reduce the server's load.<br><br><strong>See also: <br></strong><a href="https://www.devexpress.com/Support/Center/p/T124512">ASPxGridView - How to implement cascading comboboxes in Batch Edit mode</a><strong><br></strong></p>
```js
var lastCountryID;
var lastCityID;
function CountriesCombo_SelectedIndexChanged(s, e) {
var currentCountryID = s.GetSelectedItem().value;
lastCountryID = currentCountryID;
lastCityID = -1;
PageMethods.GetCities(lastCountryID, CitiesCombo_OnSuccessGetCities);
}
```

<br/>
To enable this functionality, add the [ScriptManager](https://docs.devexpress.com/AspNet/DevExpress.Web.ASPxScriptManager) control to the page and set its [EnablePageMethods](https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.scriptmanager.enablepagemethods?redirectedfrom=MSDN&view=netframework-4.8.1#System_Web_UI_ScriptManager_EnablePageMethods) property to `true`.

```aspx
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
```

## Files to Review

* [Default.aspx](./CS/Default.aspx) (VB: [Default.aspx](./VB/Default.aspx))
* [Default.aspx.cs](./CS/Default.aspx.cs) (VB: [Default.aspx.vb](./VB/Default.aspx.vb))
* [JavaScript.js](./CS/JavaScript.js) (VB: [JavaScript.js](./VB/JavaScript.js))

## Documentation

* [Grid in Batch Edit Mode](https://docs.devexpress.com/AspNet/16443/components/grid-view/concepts/edit-data/batch-edit-mode)
* [GridViewDataComboBoxColumn](https://docs.devexpress.com/AspNet/DevExpress.Web.GridViewDataComboBoxColumn)
* [Script Manager](https://docs.devexpress.com/AspNet/DevExpress.Web.ASPxScriptManager)
Binary file added WebMethodsInGrid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"runOnWeb": true,
"autoGenerateVb": false
}
"autoGenerateVb": true,
"useLegacyVbConverter": true
}