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

ListView / Declarative definition

  CustomerID CompanyName ContactName ContactTitle Address
ALFKI Alfreds Futterkiste Maria Anders Sales Representative Obere Str. 57
ANATR Ana Trujillo Emparedados y helados Ana Trujillo Owner Avda. de la Constitución 2222
ANTON Antonio Moreno Taquería Antonio Moreno Owner Mataderos 2312
AROUT Around the Horn Thomas Hardy Sales Representative 120 Hanover Sq.
BERGS Berglunds snabbköp Christina Berglund Order Administrator Berguvsvägen 8
BLAUS Blauer See Delikatessen Hanna Moos Sales Representative Forsterstr. 57
BLONP Blondesddsl père et fils Frédérique Citeaux Marketing Manager 24, place Kléber
BOLID Bólido Comidas preparadas Martín Sommer Owner C/ Araquil, 67
BONAP Bon app' Laurence Lebihan Owner 12, rue des Bouchers
BOTTM Bottom-Dollar Markets Elizabeth Lincoln Accounting Manager 23 Tsawassen Blvd.

  • This example demonstrates the declarative creation of the RadListView control. This basic setup shows the declaration of the main elements of the control:

    • AlternatingItemTemplate - determines the layout for the alternating items in the control
    • EmptyDataTemplate - determines the layout of the contents which will be rendered by the control in case no records are returned from the underlying data source
    • ItemTemplate - determines the layout of the items in the control
    • LayoutTemplate - Defines the basic template that governs the main layout of the control. It contains a placeholder object, such as a table row (tr), div, or span element. This element will be replaced with the content that is defined in the ItemTemplate/AlternatingItemTemplate. It might also contain a DataPager object.
    • EditItemTemplate - Defines the structure of the edit form, which will be rendered when the control enters edit mode.

    The LayoutTemplate contains a RadDataPager control, which is used to navigate among the records in the control.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" %>

    <%@ 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="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" />
        <script runat="server">
            private void Header1_SkinChanged(object sender, SkinChangedEventArgs e)
            {
                RadListView1.Skin = e.Skin;
                RadListView1.Rebind();
            }

            protected void Page_PreRender(object sender, EventArgs e)
            {
                RadListView1.Skin = Header1.CurrentSkin;
            }
        </script>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
        <div>
            <telerik:Header runat="server" ID="Header1" NavigationLanguage="CS" ShowSkinChooser="true" OnSkinChanged="Header1_SkinChanged" />
            <!-- content start -->
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
            <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" />
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
            <telerik:RadAjaxPanel runat="server" ID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1">
                <telerik:RadListView runat="server" ID="RadListView1" AllowPaging="True" DataKeyNames="CustomerID"
                    DataSourceID="SqlDataSource1">
                    <LayoutTemplate>
                        <div class="RadListView RadListView_<%#Container.Skin %>">
                            <table cellspacing="0" style="width: 100%;">
                                <thead>
                                    <tr class="rlvHeader">
                                        <th>
                                            &nbsp;
                                        </th>
                                        <th>
                                            CustomerID
                                        </th>
                                        <th>
                                            CompanyName
                                        </th>
                                        <th>
                                            ContactName
                                        </th>
                                        <th>
                                            ContactTitle
                                        </th>
                                        <th>
                                            Address
                                        </th>
                                    </tr>
                                </thead>
                                <tfoot>
                                    <tr>
                                        <td colspan="6">
                                            <telerik:RadDataPager ID="RadDataPager1" runat="server">
                                                <Fields>
                                                    <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                                </Fields>
                                            </telerik:RadDataPager>
                                        </td>
                                    </tr>
                                </tfoot>
                                <tbody>
                                    <tr id="itemPlaceholder" runat="server">
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <tr class="rlvI">
                            <td>
    <asp:Button ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
    CssClass="rlvBEdit" Text=" " ToolTip="Edit" />

                            </td>
                            <td>
                                <asp:Label ID="CustomerIDLabel" runat="server" Text='<%# Eval("CustomerID") %>' />
                            </td>
                            <td>
                                <asp:Label ID="CompanyNameLabel" runat="server" Text='<%# Eval("CompanyName") %>' />
                            </td>
                            <td>
                                <asp:Label ID="ContactNameLabel" runat="server" Text='<%# Eval("ContactName") %>' />
                            </td>
                            <td>
                                <asp:Label ID="ContactTitleLabel" runat="server" Text='<%# Eval("ContactTitle") %>' />
                            </td>
                            <td>
                                <asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Address") %>' />
                            </td>
                        </tr>
                    </ItemTemplate>
                    <AlternatingItemTemplate>
                        <tr class="rlvA">
                            <td>
    <asp:Button ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
    CssClass="rlvBEdit" Text=" " ToolTip="Edit" />

                            </td>
                            <td>
                                <asp:Label ID="CustomerIDLabel" runat="server" Text='<%# Eval("CustomerID") %>' />
                            </td>
                            <td>
                                <asp:Label ID="CompanyNameLabel" runat="server" Text='<%# Eval("CompanyName") %>' />
                            </td>
                            <td>
                                <asp:Label ID="ContactNameLabel" runat="server" Text='<%# Eval("ContactName") %>' />
                            </td>
                            <td>
                                <asp:Label ID="ContactTitleLabel" runat="server" Text='<%# Eval("ContactTitle") %>' />
                            </td>
                            <td>
                                <asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Address") %>' />
                            </td>
                        </tr>
                    </AlternatingItemTemplate>
                    <EditItemTemplate>
                        <tr class="rlvIEdit">
                            <td>
    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" CssClass="rlvBUpdate"
    Text=" " ToolTip="Update" />

    <asp:Button ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
    CssClass="rlvBCancel" Text=" " ToolTip="Cancel" />

                            </td>
                            <td>
                                <asp:Label ID="CustomerIDLabel1" runat="server" Text='<%# Eval("CustomerID") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="CompanyNameTextBox" runat="server" CssClass="rlvInput" Text='<%# Bind("CompanyName") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="ContactNameTextBox" runat="server" CssClass="rlvInput" Text='<%# Bind("ContactName") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="ContactTitleTextBox" runat="server" CssClass="rlvInput" Text='<%# Bind("ContactTitle") %>' />
                            </td>
                            <td>
                                <asp:TextBox ID="AddressTextBox" runat="server" CssClass="rlvInput" Text='<%# Bind("Address") %>' />
                            </td>
                        </tr>
                    </EditItemTemplate>
                    <EmptyDataTemplate>
                        <div class="RadListView RadListView_<%#Container.Skin %>">
                            <div class="rlvEmpty">
                                There are no items to be displayed.</div>
                        </div>
                    </EmptyDataTemplate>
                </telerik:RadListView>
            </telerik:RadAjaxPanel>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                ProviderName="System.Data.SqlClient" SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address] FROM [Customers]" />
            <!-- content end -->
            <telerik:Footer runat="server" ID="Footer1"></telerik:Footer>
        </div>
        </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-2012 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451