Click here to Skip to main content
15,884,709 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I used combo box(with 2 default values) in one of the column of a devexpress gridview. How to get the selected value of that combo box?

ie, in dx:ASPxGridView control, I have combobox like this

ASP.NET
<dx:GridViewDataTextColumn FieldName="selectState" Caption="selectState" VisibleIndex="1" >
                   <dataitemtemplate>
                     <dx:ASPxComboBox ID="selectState1"  runat="server" Value='<%#Bind("selectState") %>' Width="70px" EnableCallbackMode="true" >
                       <items>
                         <dx:listedititem Text="on" Value="on" />
                         <dx:listedititem Text="off" Value="off" />                        
                       </items>                     
                     </dx:ASPxComboBox>
                   </dataitemtemplate>
               </dx:GridViewDataTextColumn>


how to get the selected value of the combo box?
Thanks in advance
Posted
Updated 25-Nov-13 23:38pm
v3
Comments
Thomas ktg 26-Nov-13 1:14am    
You mean you have a combo box kept inside the DevExpress GridView And want to get the selected value of the Combo Box?
sunpop 26-Nov-13 1:16am    
yes
demouser743 26-Nov-13 9:32am    
What is Items here when you are binding value to the combobox, generally ASPxComboBox in ASPxGridview should be binded in Init event of the combo box

1 solution

Use this below code to get the selected value from the ComboBox.
C#
for (int row = 0; row < gridview1.VisibleRowCount; row++)
{
 ASPxComboBox ddlStatus = (ASPxComboBox)gridview1.FindRowCellTemplateControl(row, null, "ddlStatus");
    string status = ddlStatus.SelectedValue;
}
 
Share this answer
 
v3
Comments
sunpop 26-Nov-13 1:49am    
thank u! I'll let u know the status soon
sunpop 26-Nov-13 5:36am    
I've updated the question. Could you please check?
Thomas ktg 26-Nov-13 5:39am    
Did you try this code?
sunpop 26-Nov-13 6:06am    
sorry, what is gvHomework in your code? And I want to get the value when the DropDownList is changed(selected)
Thomas ktg 26-Nov-13 6:09am    
See my updated solution and let me know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900