I'm using : ASPxComboBox
The problem is how to set selectedValue from code behind? If my html is like this:
<dxe:ASPxComboBox ID="cbxJobType" runat="server" width="200px" MaxLength="50">
<Items>
<dxe:ListEditItem Text="Contract" Value="0" />
<dxe:ListEditItem Text="Full Time" Value="1" />
<dxe:ListEditItem Text="Part Time" Value="2" />
</Items>
<ValidationSettings ErrorDisplayMode="ImageWithTooltip">
<RequiredField ErrorText="Required Value" IsRequired="True" />
</ValidationSettings>
</dxe:ASPxComboBox>
Client-Side Script
Give ClientInstanceName property to comboBoxto access it client side and ID property as cbxJobType to access control server side.
// by text
comboBox.SetText('Text #2');
// by value
comboBox.SetValue('Value #2');
// by index
comboBox.SetSelectedIndex(1);
Server-Side Code
// by text
cbxJobType.Text = "Text #2";
// by value
cbxJobType.Value = "Value #2";
// by index
cbxJobType.SelectedIndex = 1;
This code works fine too:
cbxJobType.SelectedItem = cbxJobType.Items.FindByValue("Value #2");