Hi,
I'm using devexpress ASPxComboBox, however I wanted to know how I can allow the user to enter values(in case it is not in the list) or choose from a dropdown list.
An example would be great!
Thanks,
Tim
Hi,
I'm using devexpress ASPxComboBox, however I wanted to know how I can allow the user to enter values(in case it is not in the list) or choose from a dropdown list.
An example would be great!
Thanks,
Tim
Hi Tim,
I have written a code which allows you to add a new Item to the ComboBox's Items collection if the Enter key is pressed.
<script type="text/javascript">
function findItemByText(editor, newText) {
for(var i = 0; i< editor.GetItemCount(); i++)
if(editor.GetItem(i).text == newText)
return true;
return false;
}
function tryAddNewItem(editor, newText) {
if(!findItemByText(editor, newText))
editor.AddItem(newText);
}
</script>
...
<dx:ASPxComboBox ID="ASPxComboBox1" runat="server" DropDownStyle="DropDown" ValueType="System.String"
Width="286px">
<Items>
<dx:ListEditItem Text="Item 0" Value="0" />
<dx:ListEditItem Text="Item 1" Value="1" />
</Items>
<ClientSideEvents KeyPress="function(s,e) {
if(e.htmlEvent.keyCode == 13)
tryAddNewItem(s, s.GetText());
}"/>