How to use combobox in devexpress aspxgridview

Go To StackoverFlow.com

1

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.

Thanks

2012-04-04 21:10
by user466663


1

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

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

2012-04-07 13:37
by Guruparan


0

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">
            <EditItemTemplate>
                <cc1:DropDownList ID="DropDownList1" runat="server">
                </cc1:DropDownList>
            </EditItemTemplate>
        </dx:GridViewDataTextColumn>

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


0

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


0

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"
    CellStyle-VerticalAlign="Top">

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


0

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`
        <Items>
            <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" />
       </Items>
   </PropertiesComboBox>
   <CellStyle Font-Size="XX-Small">
   </CellStyle>
</dx:GridViewDataComboBoxColumn>
2015-07-09 17:22
by Maximus56
Ads