VB.NET•View a Table

Listing 1. Use the Repeater control with template tags to create the classic rows and columns view. This code creates a table view of the SQL Server Authors database table.

<asp:Repeater id="pubsRepeater" runat="server">
   <HeaderTemplate>
      <table border=0 width=100%>
         <tr>
            <td><b>First Name</b></td>
            <td><b>Address</b></td>
            <td><b>City</b></td>
            <td><b>State</b></td>
            <td><b>Zip</b></td>
            <td><b>Phone</b></td>
         </tr>
   </HeaderTemplate>
   <ItemTemplate>
      <tr>
         <td><%# Container.DataItem("au_lname") %></td>
         <td><%# Container.DataItem("au_fname") %></td>
         <td><%# Container.DataItem("address") %></td>
         <td><%# Container.DataItem("city") %></td>
         <td><%# Container.DataItem("state") %></td>
         <td><%# Container.DataItem("zip") %></td>
         <td><%# Container.DataItem("phone") %></td>
      </tr>
   </ItemTemplate>
   <AlternatingItemTemplate>
      <tr bgcolor=Gray>
         <td><%# Container.DataItem("au_lname") %></td>
         <td><%# Container.DataItem("au_fname") %></td>
         <td><%# Container.DataItem("address") %></td>
         <td><%# Container.DataItem("city") %></td>
         <td><%# Container.DataItem("state") %></td>
         <td><%# Container.DataItem("zip") %></td>
         <td><%# Container.DataItem("phone") %></td>
      </tr>
   </AlternatingItemTemplate>            
   <SeparatorTemplate>
   </SeparatorTemplate>         
   <FooterTemplate>
      </table>
   </FooterTemplate>
</asp:Repeater>