How to: Bind the radio button list to a data source inside the ASPxGridView's edit form template

  • 2 minutes to read

This example demonstrates how to bind the ASPxRadioButtonList control to a data source inside the grid view's edit form template.

In this example, the grid view's edit form template (accessed from the Edit Form markup section or the GridViewTemplates.EditForm property) is populated with a radio button list and Update and Cancel Template Replacements. The radio button list is bound to the third grid's column (Value='<%# Bind("CategoryID") %>') and allows users to specify a product category.

The list of product categories is stored in the AccessDataSource2 data storage that is bound to the radio button list as a data source (DataSourceID="AccessDataSource2"). The ASPxListEdit.TextField and ASPxListEdit.ValueField properties (TextField="CategoryName" ValueField="CategoryID") specify the data source fields that populate radio button list items.

As a result, the grid view's edit form allows end-users to select a product category by its name and pass it as an integer value to the grid's column.


<dx:ASPxGridView ID="ASPxGridView1" runat="server" DataSourceID="AccessDataSource1" ClientInstanceName="masterGrid" AutoGenerateColumns="False" KeyFieldName="ProductID"> 
        <dx:GridViewCommandColumn ShowEditButton="True" /> 
        <dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0"> 
            <EditFormSettings Visible="False" /> 
                <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1"> 
                <dx:GridViewDataTextColumn FieldName="CategoryID" VisibleIndex="2"> 
    <SettingsBehavior AllowFocusedRow="true" ProcessSelectionChangedOnServer="true" /> 
    <Settings ShowFilterRow="True" ShowHeaderFilterButton="true" ShowGroupPanel="True" ShowFooter="true" /> 
            <dx:ASPxRadioButtonList ID="ASPxRadioButtonList1" runat="server" Value='<%# Bind("CategoryID") %>' ValueType="System.Int32"
                DataSourceID="AccessDataSource2" TextField="CategoryName" ValueField="CategoryID"> 
            <dx:ASPxGridViewTemplateReplacement ID="ASPxGridViewTemplateReplacement1" ReplacementType="EditFormUpdateButton" runat="server" /> 
            <dx:ASPxGridViewTemplateReplacement ID="ASPxGridViewTemplateReplacement2" ReplacementType="EditFormCancelButton" runat="server" />