Speed up development with full-stack environments for every branch.

Learn More

ASP.net How to use repeater

11238 Runs 71191 Views 24695 Copies
Saved

Saved

invincibleideas 20

invincibleideas
published 4 years ago

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>ASP.net how to use repeater</title>
    <style type="text/css">
        #divEmployees
        {
            font-family:Arial, Verdana, Sans-Serif;
            font-size:12px;
            padding:10px;
            border:solid 1px #0066CC;
        }
        
        #divEmployees .detail
        {
            border-bottom:dashed 1px #0066CC;
            margin-bottom:10px;
            padding:10px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <fieldset>
            <h2>How to Use Repeater Control</h2>
        <div>
        <asp:Repeater ID="rptEmployees" runat="server">
            <HeaderTemplate>
                <div id="divEmployees">
            </HeaderTemplate>
            <ItemTemplate>
                <div class="detail">
                   <div>Name: <strong><%# Eval("FirstName") %> <%# Eval("LastName") %></strong></div>
                   <div>Address: <strong><%# Eval("Address") %></strong></div>
                   <div>State: <strong><%# Eval("State")%></strong></div>
                   <div>City: <strong><%# Eval("City")%></strong></div>
                   <div>Country: <strong><%# Eval("Country")%></strong></div>
                </div>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <div class="detail">
                   <div>Name: <strong><%# Eval("FirstName") %> <%# Eval("LastName") %></strong></div>
                   <div>Address: <strong><%# Eval("Address") %></strong></div>
                   <div>State: <strong><%# Eval("State")%></strong></div>
                   <div>City: <strong><%# Eval("City")%></strong></div>
                   <div>Country: <strong><%# Eval("Country")%></strong></div>
                </div>
            </AlternatingItemTemplate>
            <FooterTemplate>
                </div>
            </FooterTemplate>
        </asp:Repeater>
        </div>
        </fieldset>
    </div>
    </form>
</body>
</html>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).