<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RepeaterExample2.aspx.cs" Inherits="Repeater.RepeaterExample2" %>

 

<!DOCTYPE html>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

    <title>Repeater Example</title>

</head>

<body bgcolor="#ffcc66">

 

    <h3>This example demonstrates dynamically displayed data from an ArrayList with a Repeater control.</h3>

   

    <div>

    <form id="form1" runat="server">

 

        <table>

This manually binds the “ProductId” Property of an object in the ArrayList to the Text Property of the label for each row that is generated. The value displayed in this control’s Text Property for each generated row will be the value of the “ProductId” Property for a specific object in the datasource.

 
            <tr style="color: #CC3300;">

                <th>Product ID</th>

                <th>Description</th>

                <th>Price</th>

                <th>Quantity in stock</th>

            </tr>

 

            <asp:Repeater ID="rptProducts" runat="server">

                <ItemTemplate>

                    <tr>

                        <td>

                            <asp:Label ID="lblProductID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ProductId") %>'></asp:Label>

                        </td>

                        <td>

                            <asp:Label ID="lblDescription" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>'></asp:Label>

                        </td>

                        <td>

                            <asp:Label ID="lblPrice" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>'></asp:Label>

                        </td>

                        <td>

                            <asp:Label ID="lblQOH" runat="server" Text='<%# Bind("QOH") %>'></asp:Label>

                        </td>

                    </tr>               

                </ItemTemplate>

            </asp:Repeater>

           

        </table>

  

    </form>

    </div>

 

</body>

</html>