How to use combobox in devexpress aspxgridview

Go To


I am displaying my data in a devexpress gridview. One of the column is state value. When the grid is edited, I have to show the state in a combobox, so that the user could change the state by choosing a different state. Currently it is displayed in a textbox, since it is the default. Essentially when the user clicks the edit button, a combobox should be displayed as part of the edit controls, and the combobox should be populated with all possible states in the codebehind and the selected value should be the initial value on the grid. It is very easy do it in MS gridview. But I couldn't see any sample code for how to do it in the devexpress gridview.


2012-04-04 21:10
by user466663


  <dx:GridViewDataTextColumn FieldName="FieldName" VisibleIndex="4">
                <dx:ASPxComboBox ID="ASPxComboBox1" runat="server" DataSourceID="newDataSource" >

You'll need to set the datasource so you'll get the list of values

2012-04-07 13:37
by Guruparan


Edit the GridView Template, and in the EditTemplate of the field, add the dropdownbox. It might come to look like this

<dx:GridViewDataTextColumn Caption="Field Name" 
            FieldName="FieldName" VisibleIndex="3">
                <cc1:DropDownList ID="DropDownList1" runat="server">

So when you edit that row, it will show the DDL

2012-04-04 21:21
by CJLopez
Thanks for the quick reply. It puts the combobox. However it is an empty one. Please let me know how to populate it with the states and set the selected value as the one which was on the gridview - user466663 2012-04-04 21:36
Just do what Guruparan said, but thats the case when you have a datasource, if you need to get the data, from, lets say, an enumeration, well, you'll need to get the reference control within the EditTemplat - CJLopez 2012-04-10 17:12


Use GridViewDataComboBoxColumn. Declare datasource and attach it to combo box column or populate it in code behind. This example contains both variants.
You can also take a look at DevExpress grid editing demos.

2012-04-05 07:17
by Filip


I have used the following code to have combo box in the aspxgridview.

I hope this example helps :

    <dx:GridViewDataComboBoxColumn FieldName="DatabaseFieldName" Settings-FilterMode="DisplayText"
Width="3%" VisibleIndex="3" Visible="True" Caption="Priority" Settings-AutoFilterCondition="Contains"
 HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center"

    <PropertiesComboBox ValueType="System.String" DataSourceID="objDataSourceID"
 Width="200px" Height="25px" TextField="TextFieldName" ValueField="ValueFieldName"
2012-07-31 16:26
by Ruchi


If you don't have a data source and want to include the combo box items in your code, here's another way to create the column:

<dx:GridViewDataComboBoxColumn FieldName="QAAproval" VisibleIndex="11" Width="30px">
    <PropertiesComboBox>`enter code here`
            <dx:ListEditItem Text="GENERIC" Value="GENERIC" />
            <dx:ListEditItem Text="FAIR" Value="FAIR" />
            <dx:ListEditItem Text="VSE" Value="VSE" />
            <dx:ListEditItem Text="ECAV" Value="ECAV" />
            <dx:ListEditItem Text="FMMDS" Value="FMMDS" />
            <dx:ListEditItem Text="CLEAR" Value="CLEAR" />
   <CellStyle Font-Size="XX-Small">
2015-07-09 17:22
by Maximus56