Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding empty string to RadComboBox

I have a webpage that has a Telerik RadComboBox on the page. One of the properties of this ComboBox is EmptyMessage, which fills the combobox with a message when an item is not selected. I am binding my combobox to a datasource at runtime and for some reason, it wipes this EmptyMessage away. Is there a way to keep my data items in tact and have the empty message there too? And default it to the empty message?

like image 444
Icemanind Avatar asked Jun 08 '09 20:06

Icemanind


3 Answers

Seems like the accepted answer on Telerik says that you use client side script to prevent the text editing.

Telerik forum page

<telerik:Radcombobox ID="RadComboBox1" runat="server" AllowCustomText="True" EmptyMessage="-please select one-">    
<Items>     
    <telerik:RadComboBoxItem runat="server" Text="Item1"></telerik:RadComboBoxItem>     
    <telerik:RadComboBoxItem runat="server" Text="Item2"></telerik:RadComboBoxItem>     
</Items>    

<script type="text/javascript"> 
function pageLoad() 
{ 
   var combo = $find("<%= RadComboBox1.ClientID %>"); 
   var input = combo.get_inputDomElement(); 
   input.onkeydown = onKeyDownHandler; 
} 
function onKeyDownHandler(e) 
{ 
  if (!e) 
  e = window.event;        
  e.returnValue = false; 
  if (e.preventDefault) 
  { 
    e.preventDefault(); 
  } 
} 
</script> 
like image 195
starskythehutch Avatar answered Nov 09 '22 02:11

starskythehutch


RadComboBox1.Items.Insert(0, New RadComboBoxItem("Select a continent"))

This will add "Select a continent" as the first item in the combobox.

like image 5
te. Avatar answered Nov 09 '22 04:11

te.


just put this

 ComboBox.Text = String.Empty
like image 1
Syed Umar Ahmed Avatar answered Nov 09 '22 02:11

Syed Umar Ahmed