ComboBox

Controls

Rate this demo

Thank you for your post!
Submit a support ticket
If you have an active license or trial, you have access to dedicated support from Telerik’s developers. Response time is 24h for active licenses and 72h for trials, Mon-Fri.
Post in the forums
If you don’t have access to support or would like to help other people by sharing your problem, reach out to our active community in the forums.

ComboBox - Add/Remove/Disable Items

select
Available actions

RadComboBox provides rich server-side API. It allows the developer to easily add, remove or disable items.

To add an item to the combo, simply create a new RadComboBoxItem instance and add it to the Items collection of the combo, e.g
RadComboBox1.Items.Add( new RadComboBoxItem("Some Item") );

To remove an item, simply call the Remove() method of the item.

To disable an item, just set the Enabled property of the combo to false.
C# VB
Show code in new window Demo isolation steps
<%@ Page AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="ComboBox.Examples.Programming.AddRemoveDisable.DefaultCS"Language="c#"  %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <title>ASP.NET ComboBox Demo - Add/Remove/Disable Items</title>
</head>

<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="QsfSkinManager" runat="server" ShowChooser="true" />
    <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />

     <div class="qsf-demo-canvas qsf-demo-canvas-vertical">
          <telerik:RadComboBox ID="RadComboBox1" runat="server" Height="140" Width="210" />
     </div>

     <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Title="Available actions"
          Orientation="Vertical" Expanded="true">
          <ul>
               <li>
                    <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" Text="Native Rendering Mode" />
               </li>
               <li>
                    <asp:Button ID="LinkButton1" runat="server" CausesValidation="False"
                         OnClick="LinkButton1_Click" Text="Disable Selected Item" />
               </li>
               <li>
                    <asp:Button ID="Linkbutton4" runat="server" CausesValidation="False"
                         OnClick="Linkbutton4_Click" Text="Enable All Items" />
               </li>
               <li>
                    <asp:Button ID="LinkButton2" runat="server" CausesValidation="False"
                         OnClick="LinkButton2_Click" Text="Delete Selected Item" />
               </li>
               <li>
                    <asp:TextBox runat="server" ID="TextBox1" Width="220" />
                    <asp:Button ID="Linkbutton3" runat="server" OnClick="Linkbutton3_Click"
                         ValidationGroup="AddButton" Text="Add New Item" />
                    <br />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                         ControlToValidate="TextBox1" ValidationGroup="AddButton"
                         ErrorMessage="Cannot add empty items." Display="Dynamic" />
               </li>
          </ul>
     </qsf:ConfiguratorPanel>

    </form>
</body>
</html>