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

Programmatic definition

The actual data editing logic is omitted for brevity
  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 dynamic (programmatic) 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.

As with any control, the RadListView control can be created dynamically, to allow for more flexibility. As with any other control which uses templates, the structure needs to be created in the PageInit event handler. Each type of template can be created using a separate class do define its structure.
  • DefaultVB.aspx
  • DefaultVB.aspx.vb
<%@ Page Language="vb" AutoEventWireup="false" Inherits="Telerik.ListViewExamplesVBNET.DefiningStructure.ProgrammaticDefinition.DefaultVB"CodeFile="DefaultVB.aspx.vb"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!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" />
    <qsf:MessageBox ID="InfoMessageBox" Type="Info" Icon="Info" runat="server">
        The actual data editing logic is omitted for brevity
    </qsf:MessageBox>
    <div class="demo-container no-bg">
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1">
            <asp:PlaceHolder runat="server" ID="PlaceHolder1"></asp:PlaceHolder>
        </telerik:RadAjaxPanel>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT TOP 10 [CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address] FROM [Customers]"></asp:SqlDataSource>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance