Repeater with Table : Repeater « ASP.net Controls « ASP.NET Tutorial






<%@ Page Language="C#" %>

<!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>Like a Grid</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
            <HeaderTemplate>
                <thead>
                    <td> <b>ID</b> </td>
                    <td> <b>First Name</b> </td>
                    <td> <b>Last Name</b> </td>
                </thead>
            </HeaderTemplate>

            <ItemTemplate>
            <tr>
                <td bgcolor="white"> 
                    <%# Eval("EmployeeID") %></td>
                <td bgcolor="white"> 
                    <%# Eval("FirstName")%></td>
                <td bgcolor="white">
                    <%# Eval("LastName") %></td>
            </tr>
            </ItemTemplate>

            <AlternatingItemTemplate>
            <tr>
                <td bgcolor="#eeeeee"> 
                    <%# Eval("EmployeeID") %></td>
                <td bgcolor="#eeeeee"> 
                    <%# Eval("FirstName")%></td>
                <td bgcolor="#eeeeee"> 
                    <%# Eval("LastName") %></td>
            </tr>
            </AlternatingItemTemplate>
            
            <FooterTemplate>
            </FooterTemplate>
        </asp:Repeater>
        
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:NorthWind %>"
            SelectCommand="SELECT employeeid, firstname, lastname FROM employees">
        </asp:SqlDataSource>

    </div>
    </form>
</body>
</html>








3.24.Repeater
3.24.1.Bind data from Access database to an ASP:Repeater (VB.net)
3.24.2.Repeater with Table