Grid View for ASP.NET Web Forms - How to use WebMethods to implement cascading combo boxes in batch edit mode
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
- Combo Box for ASP.NET Web Forms - How to use the WebMethod attribute to populate a cascading editor with data
The main idea is to use WebMethods to update the secondary editor's data based on the primary editor's value.
var lastCountryID;
var lastCityID;
function CountriesCombo_SelectedIndexChanged(s, e) {
var currentCountryID = s.GetSelectedItem().value;
lastCountryID = currentCountryID;
lastCityID = -1;
PageMethods.GetCities(lastCountryID, CitiesCombo_OnSuccessGetCities);
}
To enable this functionality, add the ScriptManager control to the page and set its EnablePageMethods property to true
.
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
- JavaScript.js (VB: JavaScript.js)
(you will be redirected to DevExpress.com to submit your response)