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

TreeList / Server-side Selection

Configurator
Multi row selection
Single row selection
SportIDSport
1Winter
2Summer
SportIDSport  
1Winter
2Summer
Selected items:
Selected item:

  • The purpose of this example is to demonstrate the server-side selection capabilities of the RadTreeList control. The server-sede selection could be achieved by using the build in TreeListSelectColumn:

    <Columns>
    <telerik:TreeListSelectColumn></telerik:TreeListSelectColumn>
    </Columns>

    The alternative way is to fire the Select / Deselect commands as shown in the second (Single row selection) demo.

    Additionally, using the demo Configurator for the first RadTreeList control, you can see how the recursive selection works.
    Note that when recursive selection is enabled, the RadTreeList items are selected server-side (with postback) and multi-row selection is enabled implicitly.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="VB" AutoEventWireup="false" Inherits="Telerik.TreeListExamplesVBNET.Selecting.ServerSideSelection.DefaultVB"
        CodeFile="DefaultVB.aspx.vb" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="telerik" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!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">
        <telerik:HeadTag runat="server" ID="Headtag2"></telerik:HeadTag>
        <style type="text/css">
            .RadTreeList .rtlTable td, .RadTreeList .rtlTable th
            {
                line-height: 1.3;
            }
            .siFieldset
            {
                width: 410px;
                padding: 10px;
            }
        </style>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
        <telerik:Header runat="server" ID="Header1" NavigationLanguage="VB" />
        <!-- content start -->
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadTreeList1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadTreeList1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="SelectedItemsLabel" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadTreeList2">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadTreeList2" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="SelectedItemLabel" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="CheckBox1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadTreeList1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="SelectedItemsLabel" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <table>
            <thead>
                <tr>
                    <th>
                        <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Title="Configurator">
                            <table>
                                <tr>
                                    <td>
    <asp:CheckBox OnCheckedChanged="CheckBox1_CheckedChanged" runat="server" ID="CheckBox1"
    AutoPostBack="true" Text="Allow Recursive Selection (Used in multi row selection example) " />

                                    </td>
                                </tr>
                            </table>
                        </qsf:ConfiguratorPanel>
                        Multi row selection
                    </th>
                    <th>
                        Single row selection
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr valign="top">
                    <td>
                        <telerik:RadTreeList ID="RadTreeList1" runat="server" Width="430px" OnNeedDataSource="RadTreeList1_NeedDataSource"
                            DataKeyNames="ID" ParentDataKeyNames="TypeID" AutoGenerateColumns="false" AllowMultiItemSelection="true">
                            <Columns>
                                <telerik:TreeListSelectColumn HeaderStyle-Width="38px">
                                </telerik:TreeListSelectColumn>
                                <telerik:TreeListBoundColumn DataField="ID" HeaderText="SportID" HeaderStyle-Width="80px" UniqueName="ID" />
                                <telerik:TreeListBoundColumn DataField="Name" HeaderText="Sport" UniqueName="Name" />
                            </Columns>
                        </telerik:RadTreeList>
                    </td>
                    <td>
                        <telerik:RadTreeList ID="RadTreeList2" runat="server" Width="430px" OnNeedDataSource="RadTreeList1_NeedDataSource"
                            DataKeyNames="ID" ParentDataKeyNames="TypeID" AutoGenerateColumns="false">
                            <ItemStyle VerticalAlign="Middle" />
                            <Columns>
                                <telerik:TreeListBoundColumn DataField="ID" HeaderText="SportID" UniqueName="ID" />
                                <telerik:TreeListBoundColumn DataField="Name" HeaderText="Sport" UniqueName="Name" />
                                <telerik:TreeListTemplateColumn HeaderStyle-Width="80px">
                                    <HeaderTemplate>
                                        &nbsp;
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <telerik:RadButton ID="SelectButton" runat="server" Text="+" CommandName="Select"
                                            Width="24px" />
                                        <telerik:RadButton ID="DeselectButton" runat="server" Text="-" CommandName="Deselect"
                                            Width="24px" />
                                    </ItemTemplate>
                                </telerik:TreeListTemplateColumn>
                            </Columns>
                        </telerik:RadTreeList>
                    </td>
                </tr>
                <tr>
                    <td>
                        Selected items:
                        <fieldset class="siFieldset">
                            <asp:Label ID="SelectedItemsLabel" runat="server" />
                        </fieldset>
                    </td>
                    <td>
                        Selected item:
                        <fieldset class="siFieldset">
                            <asp:Label ID="SelectedItemLabel" runat="server" />
                        </fieldset>
                    </td>
                </tr>
            </tbody>
        </table>
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="Fieldset" />
        <!-- content end -->
        <telerik:Footer runat="server" ID="Footer1"></telerik: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