ListView - Migration from ASP.NET ListView

RadListView

  • Chai
  • 10 boxes x 20 bags
  • $18.00
  • 39
  • False
  • Chang
  • 24 - 12 oz bottles
  • $19.00
  • 17
  • False
  • Aniseed Syrup
  • 12 - 550 ml bottles
  • $10.00
  • 13
  • False

ASP.NET ListView

  • Chai
  • 10 boxes x 20 bags
  • $18.00
  • 39
  • False
  • Chang
  • 24 - 12 oz bottles
  • $19.00
  • 17
  • False
  • Aniseed Syrup
  • 12 - 550 ml bottles
  • $10.00
  • 13
  • False

Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB

The declarative syntax of Telerik RadListView is quite similar to that of the Microsoft ListView control, which makes the migration a pretty straightforward task. Compare the source codes in the ASPX tab.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page Language="c#" Inherits="Telerik.ListViewExamplesCSharp.Migration.DefaultCS"CodeFile="DefaultCS.aspx.cs"  %>

<%@ 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">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" />
</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">
        <!-- content start -->
        <table>
            <tr>
                <td class="offset">
                    <h3>
                        RadListView</h3> 
                    <telerik:RadListView ID="RadListView1" DataSourceID="SqlDataSource1" runat="server" RenderMode="Lightweight" 
                        ItemPlaceholderID="ProductItemContainer">
                        <LayoutTemplate>
                            <fieldset id="ProductItemContainer" runat="server">
                            </fieldset>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <ul>
                                <li>
                                    <label>
                                        Product name:</label>
                                    <%#Eval("ProductName")%>
                                </li>
                                <li>
                                    <label>
                                        Quantity per unit:</label>
                                    <%#Eval("QuantityPerUnit")%>
                                </li>
                                <li>
                                    <label>
                                        Unit price:</label>
                                    <%# DataBinder.Eval(Container.DataItem, "UnitPrice", "{0:C}")%>
                                </li>
                                <li>
                                    <label>
                                        Units in stock:</label>
                                    <%#Eval("UnitsInStock")%>
                                </li>
                                <li>
                                    <label>
                                        Discontinued:</label>
                                    <%#Eval("Discontinued")%>
                                </li>
                            </ul>
                        </ItemTemplate>
                    </telerik:RadListView>
                </td>
                <td>
                    <h3>
                        ASP.NET ListView</h3>
                    <asp:ListView ID="ListView1" DataSourceID="SqlDataSource1" runat="server" ItemPlaceholderID="ProductItemContainer">
                        <LayoutTemplate>
                            <fieldset id="ProductItemContainer" runat="server">
                            </fieldset>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <ul>
                                <li>
                                    <label>
                                        Product name:</label>
                                    <%#Eval("ProductName")%>
                                </li>
                                <li>
                                    <label>
                                        Quantity per unit:</label>
                                    <%#Eval("QuantityPerUnit")%>
                                </li>
                                <li>
                                    <label>
                                        Unit price:</label>
                                    <%# DataBinder.Eval(Container.DataItem, "UnitPrice", "{0:C}")%>
                                </li>
                                <li>
                                    <label>
                                        Units in stock:</label>
                                    <%#Eval("UnitsInStock")%>
                                </li>
                                <li>
                                    <label>
                                        Discontinued:</label>
                                    <%#Eval("Discontinued")%>
                                </li>
                            </ul>
                        </ItemTemplate>
                    </asp:ListView>
                </td>
            </tr>
        </table>
        <br/>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT TOP 3 ProductID, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock, Discontinued FROM Products">
        </asp:SqlDataSource>
        <!-- content end -->
    </div>
    </form>
</body>
</html>

Find Assistance

Help Us Improve

Was this example helpful?