Skip to content

Latest commit

 

History

History
63 lines (48 loc) · 4.24 KB

File metadata and controls

63 lines (48 loc) · 4.24 KB

Grid View for ASP.NET Web Forms - How to use cascading combo boxes in inline edit mode

This example demonstrates how to create templated combo box columns, add cascading combo box editors to the templates, and configure the grid's cell edit functionality in inline mode.

Cascading combo boxes in inline edit mode

Overview

Add combo box columns to the grid, specify their EditItemTemplate properties, and add combo box editors to the templates.

<dx:GridViewDataComboBoxColumn FieldName="Category1ID" VisibleIndex="4">
    <PropertiesComboBox DataSourceID="dsCategory1" TextField="Name" ValueField="ID" ValueType="System.Int32" />
    <EditItemTemplate>
        <dx:ASPxComboBox ID="Cat1" runat="server" DataSourceID="dsCategory1" TextField="Name" ValueField="ID"
            Value='<%# Bind("Category1ID") %>' AutoPostBack="true" ValueType="System.Int32"
            OnSelectedIndexChanged="Cat1_SelectedIndexChanged">
        </dx:ASPxComboBox>
    </EditItemTemplate>
</dx:GridViewDataComboBoxColumn>

For every template editor, handle its server-side SelectedIndexChanged event. In handlers, call the grid's FindEditRowCellTemplateControl method to access the subsequent editor and filter its data source based on the selected value of the primary editor.

protected void Cat1_SelectedIndexChanged(object sender, EventArgs e) {
    ASPxComboBox combo1 = (ASPxComboBox)sender;
    object oldCat1 = Session["Cat1ID"];
    if(oldCat1 != null && oldCat1.Equals(combo1.Value)) return;
    Session["Cat1ID"] = combo1.Value;
    ASPxComboBox combo2 = ((ASPxComboBox)grid.FindEditRowCellTemplateControl(
        grid.Columns["Category2ID"] as GridViewDataComboBoxColumn, "Cat2"));
    combo2.Value = null;
    Cat2_SelectedIndexChanged(combo2, EventArgs.Empty);
}

Wrap the grid with an update panel to avoid updating the entire page.

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)