Back to Devexpress

GridViewDataComboBoxColumn Class

aspnet-devexpress-dot-web-f2047b04.md

latest5.3 KB
Original Source

GridViewDataComboBoxColumn Class

A combo box column in the Grid View control.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public class GridViewDataComboBoxColumn :
    GridViewEditDataColumn
vb
Public Class GridViewDataComboBoxColumn
    Inherits GridViewEditDataColumn

Remarks

When the Grid View control is in edit mode, a combo box column displays a drop-down menu. Users can select one of the items displayed in this menu.

Note

Combo box columns are not supported in database server mode.

To bind a combo box column to a data source field, assign the field name to the column’s FieldName property. The column’s PropertiesComboBox property allows you to access and configure combo box editor settings. Configure the following settings to bind the combo box editor to a data source:

DataSource or DataSourceIDAllows you to bind the combo box editor to a data source.ValueFieldSpecifies the data source field that contains combo box editor item values.ValueTypeSpecifies the data type of the combo box editor values.TextFieldSpecifies the data source field that contains the text strings displayed by the drop-down window.

Example

The following code example demonstrates how to bind the combo box column to a data source:

aspx
<dx:ASPxGridView ID="Grid" runat="server" DataSourceID="DataSource" KeyFieldName="ProductID">
    <Columns>
        <!-- ... -->
        <dx:GridViewDataComboBoxColumn FieldName="CategoryID" Caption="Category Name">
            <PropertiesComboBox DataSourceID="CategoriesDataSource"
                                ValueType="System.Int32"
                                ValueField="CategoryID"
                                TextField="CategoryName" />
        </dx:GridViewDataComboBoxColumn>
    </Columns>
    <!-- ... -->
</dx:ASPxGridView>
razor
@Html.DevExpress().GridView(settings => {
    settings.Name = "gridView";
    settings.KeyFieldName = "ProductID";
    <!-- ... -->
    settings.Columns.Add(c => {
        c.FieldName = "CategoryID";
        c.Caption = "Category";
        c.EditorProperties().ComboBox(p => {
            p.TextField = "CategoryName";
            p.ValueField = "CategoryID";
            p.ValueType = typeof(int);
            p.DataSource = NorthwindDataProvider.GetCategories();
        });
    });
    <!-- ... -->
}).Bind(Model).GetHtml()

Run Demo: ASPxGridView — Batch EditingRun Demo: MVCxGridView — Batch Editing

Implements

IStateManager

IPropertiesOwner

IExpressionsAccessor

IDataSourceViewSchemaAccessor

IFilterablePropertyInfo

IWebGridDataColumn

IWebGridColumn

Inheritance

Object StateManager CollectionItem WebColumnBase GridViewColumn GridViewDataColumn GridViewEditDataColumn GridViewDataComboBoxColumn

See Also

GridViewDataComboBoxColumn Members

Grid View

Data Columns

Passing Values from the Server to the Client

Online demo: Grid - Cascading Combo Boxes

DevExpress.Web Namespace