Friday, November 18, 2011

RadComboBox not to select any Item on Load

Problem: I am trying to set SelectedIndex to -1 with the objective that I don't any item in the RadCombo to be highlighted. Whilst the debugger passes the line the next statement says SelectedIndex 0.
How to make the RadCombo not to select any particular item automatically?
Solution: To avoid automatic selection of RadComboBox you can try any of the following approaches.
1) Set EmptyMessage property.
or
2) Add an empty text as first RadComboBoxItem.
Here is the sample ASPX,
<telerik:RadComboBox ID="RadComboBox1" runat="server"
            AutoPostBack="true"  Skin="Sunset" EnableAjaxSkinRendering="false"  >
      <Items>
            <telerik:RadComboBoxItem Text="" Value="-1" />
            <telerik:RadComboBoxItem Text="Telerik School Item 1" Value="0"  >
            </telerik:RadComboBoxItem>
            <telerik:RadComboBoxItem Text="Telerik School Item 2" Value="1">
            </telerik:RadComboBoxItem>
            <telerik:RadComboBoxItem Text="Telerik School Item 3" Value="2">
            </telerik:RadComboBoxItem>
            <telerik:RadComboBoxItem Text="Telerik School Item 4" Value="3">
            </telerik:RadComboBoxItem>
     </Items>     
</telerik:RadComboBox>

No comments:

Post a Comment