ListBox - Add/Remove/Disable items

  • Amsterdam
  • Barcelona
  • Bonn
  • Boston
  • Brussels
  • Dallas
  • Denver
  • Dublin
  • Liverpool
  • London
  • Madrid
  • Miami
  • Moscow
  • New York
  • Oslo
  • Paris
  • San Francisco
  • Seattle
  • Sofia
  • St.Paul

Demo Configurator

Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB

RadListBox 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 RadListBoxItem instance and add it to the Items collection of the combo:


RadListBox1.Items.Add(new RadListBoxItem("Some Item"));


RadListBox1.Items.Add(New RadListBoxItem("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.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • ListBox.xml
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="ListBox.Examples.ServerSide.AddRemoveDisable.DefaultCS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns=''>
<head runat="server">
    <title>Telerik ASP.NET Example</title>

    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-thin">
        <telerik:RadListBox RenderMode="Lightweight" runat="server" ID="RadListBox1" SelectionMode="Multiple" Height="200"  Width="300">

        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Select a item first." Display="Dynamic" ControlToValidate="RadListBox1" ValidationGroup="DisableRequiresSelection" CssClass="validator" />
        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Select a item first." Display="Dynamic" ControlToValidate="RadListBox1" ValidationGroup="DeleteRequiresSelection" CssClass="validator" />

    <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1">
                <ul class="fb-group">
                        <qsf:Button ID="DisableButton" runat="server" OnClick="DisableButton_Click" ValidationGroup="DisableRequiresSelection" Text="Disable selected item(s)" />
                        <qsf:Button ID="EnableAllButton" runat="server" CausesValidation="False" OnClick="EnableAll_Button" Text="Enable all items" />
                        <qsf:Button ID="DeleteButton" runat="server" OnClick="DeleteButton_Click" ValidationGroup="DeleteRequiresSelection" Text="Delete selected item(s)" />
                        <qsf:TextBox runat="Server" ID="itemTextBox" EmptyMessage="Enter item text" Size="Wide" />
                        <qsf:Button ID="AddButton" runat="server" OnClick="AddButton_Click" ValidationGroup="TextRequired" Text="Add item" Size="Narrow" />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Text is required" Display="Dynamic" ControlToValidate="itemTextBox" ValidationGroup="TextRequired" CssClass="validator" />

Find Assistance

Help Us Improve

Was this example helpful?