Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

ComboBox / Add/Remove/Disable Items

select

  • 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.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>

    <%@ Page AutoEventWireup="true" CodeFile="DefaultVB.aspx.vb" Inherits="Telerik.ComboboxExamplesVB.AddRemoveDisable.DefaultVB"
        Language="vb" %>

    <!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 runat="server">
        <qsf:headtag runat="server" ID="Headtag1"></qsf:headtag>
        
         <style type="text/css">
            .qsfRightConfig,
            .qsfRightConfig .qsfConfig
            {
                width: 400px;
                float: right;
            }
            
            #RequiredFieldValidator1,
            .qsfexAvailableActions
            {
                list-style-type: none;
                margin:0;
                padding-left: 40px;
            }
            
            #RequiredFieldValidator1,
            .qsfexAvailableActions li
            {
                float: left;
                clear: left;
                margin: 8px 0 0 0;
            }
            
            .qsfexAvailableActions .textfield
            {
                float: left;
                margin: 0 8px 0 0;
            }
            
            .qsfexAvailableActions .qsfButtonBig,
            .qsfexAvailableActions .qsfButton
            {
                text-align:center;
                color: #333;
                text-decoration: none;
                vertical-align: top;
                float: left;
                line-height: 22px;
            }
        </style>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            </telerik:RadScriptManager>
            <qsf:header runat="server" ID="Header1" NavigationLanguage="vb"></qsf:header>
            <!-- content start -->
            <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Title="Available actions" Orientation="Vertical" CssClass="qsfRightConfig" Expanded="true">
                <ul class="qsfexAvailableActions">
                    <li>
                        <asp:LinkButton CssClass="qsfButtonBig" ID="LinkButton1" runat="server" CausesValidation="False" OnClick="LinkButton1_Click">Disable Selected Item</asp:LinkButton>
                    </li>

                    <li>
                        <asp:LinkButton CssClass="qsfButtonBig" ID="Linkbutton4" runat="server" CausesValidation="False" OnClick="Linkbutton4_Click">Enable All Items</asp:LinkButton>
                    </li>

                    <li>
                        <asp:LinkButton CssClass="qsfButtonBig" ID="LinkButton2" runat="server" CausesValidation="False" OnClick="LinkButton2_Click">Delete Selected Item</asp:LinkButton>
                    </li>

                    <li>
                        <asp:TextBox runat="server" ID="TextBox1" CssClass="textfield" style="width:220px; height:20px; vertical-align: top; border:1px solid #678892;"></asp:TextBox>
                        <asp:LinkButton CssClass="qsfButton" ID="Linkbutton3" runat="server" OnClick="Linkbutton3_Click" ValidationGroup="AddButton">Add New Item</asp:LinkButton>
                    </li>
                   </ul>
                    
                    <asp:DataGrid ID="DataGrid1" runat="server" DataMember="g">
                    </asp:DataGrid>
                    
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Cannot add empty items."
    ControlToValidate="TextBox1" ValidationGroup="AddButton"></asp:RequiredFieldValidator>

           </qsf:ConfiguratorPanel>
            <telerik:RadComboBox
                ID="RadComboBox1"
                runat="server"
                Height="140px"
                Width="190px">
            </telerik:RadComboBox>

            <!-- content end -->
            <qsf:footer runat="server" ID="Footer1"></qsf:footer>
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451