New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

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

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:

C#

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

VB.NET

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.

  • DefaultVB.aspx
  • DefaultVB.aspx.vb
  • ListBox.xml
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="DefaultVB.aspx.vb" Inherits="ListBox.Examples.ServerSide.AddRemoveDisable.DefaultVB" %>

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>

<body>
    <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">
        </telerik:RadListBox>

        <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" />
    </div>

    <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1">
        <Views>
            <qsf:View>
                <ul class="fb-group">
                    <li>
                        <qsf:Button ID="DisableButton" runat="server" OnClick="DisableButton_Click" ValidationGroup="DisableRequiresSelection" Text="Disable selected item(s)" />
                    </li>
                    <li>
                        <qsf:Button ID="EnableAllButton" runat="server" CausesValidation="False" OnClick="EnableAll_Button" Text="Enable all items" />
                    </li>
                    <li>
                        <qsf:Button ID="DeleteButton" runat="server" OnClick="DeleteButton_Click" ValidationGroup="DeleteRequiresSelection" Text="Delete selected item(s)" />
                    </li>
                    <li>
                        <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" />
                    </li>
                    <li>
                    </li>
                </ul>
            </qsf:View>
        </Views>
    </qsf:ConfiguratorPanel>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance