ListView - EntityDataSource

Products
Category name: Beverages
Soft drinks, coffees, teas, beers, and ales
Category Photo
Category name: Condiments
Sweet and savory sauces, relishes, spreads, and seasonings
Category Photo
Category name: Confections
Desserts, candies, and sweet breads
Category Photo
Category name: Dairy Products
Cheeses
Category Photo
Category name: Grains/Cereals
Breads, crackers, pasta, and cereal
Category Photo
Category name: Meat/Poultry
Prepared meats
Category Photo
Category name: Produce
Dried fruit and bean curd
Category Photo
Category name: Seafood
Seaweed and fish
Category Photo
Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB

RadListView can be bound to all ASP 3.5 DataSource control types like EntityDataSource

All you need to do is set the DataSourceID property of the ListView to the ID of the Data Source control. Then you can use ASP.NET binding expressions (Eval or Bind) for the fields that will be visualized in the listview's body.

You may also see how to utilize Telerik OpenAccess ORM as a data access layer for our AJAX controls by visiting the OpenAccess ORM live demos here.

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

<%@ Register Assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>
<%@ 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" />
    <telerik:RadFormDecorator RenderMode="Lightweight" ID="RadFormDecorator1" runat="server" DecoratedControls="All" ControlsToSkip="H4H5H6" />
    <div class="demo-container">
        <telerik:RadListView ID="RadListView1" RenderMode="Lightweight" DataSourceID="EntityDataSource1" runat="server"
            ItemPlaceholderID="ProductItemContainer" DataKeyNames="CategoryID">
            <LayoutTemplate>
                <fieldset>
                    <legend>Products</legend>
                    <asp:PlaceHolder ID="ProductItemContainer" runat="server"></asp:PlaceHolder>
                </fieldset>
            </LayoutTemplate>
            <ItemTemplate>
                <fieldset class="categoryFieldset">
                    <legend>Category name:
                        <%# Eval("CategoryName") %></legend>
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="categoryDescription">
                                <table cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>
                                            <%# Eval("Description")%>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td class="categoryImage">
                                <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" AlternateText="Category Photo" CssClass="binaryImage"
                                    ToolTip="Category Photo" Width="90px" Height="110px" ResizeMode="Fit" DataValue='<%# ((byte[]) Eval("Picture")).ToArray() %>'></telerik:RadBinaryImage>
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </ItemTemplate>
        </telerik:RadListView>
        <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=NorthwindReadOnlyEntities"
            DefaultContainerName="NorthwindReadOnlyEntities" EntitySetName="Categories">
        </asp:EntityDataSource>
    </div>
    </form>
</body>
</html>

Find Assistance

Help Us Improve

Was this example helpful?