aspnet-devexpress-dot-web-f2047b04.md
A combo box column in the Grid View control.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public class GridViewDataComboBoxColumn :
GridViewEditDataColumn
Public Class GridViewDataComboBoxColumn
Inherits GridViewEditDataColumn
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.
The following code example demonstrates how to bind the combo box column to a data source:
<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>
@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
Object StateManager CollectionItem WebColumnBase GridViewColumn GridViewDataColumn GridViewEditDataColumn GridViewDataComboBoxColumn
See Also
GridViewDataComboBoxColumn Members
Passing Values from the Server to the Client