<%@ 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>Extracting Rows From Templates</title> </head> <body> <form id="form1" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthWind %>" SelectCommand="SELECT TOP 10 * FROM customers"> </asp:SqlDataSource> <asp:DataList ID="list" runat="server" DataSourceID="SqlDataSource1" ExtractTemplateRows="true" RepeatColumns="3" BorderStyle="Solid" BorderWidth="1px"> <alternatingitemstyle backcolor="PaleGoldenrod" /> <headerstyle backcolor="Brown" forecolor="White" font-size="Larger" font-bold="True" horizontalalign="Center" /> <HeaderTemplate> <asp:table ID="Table1" runat="server"> <asp:tablerow ID="Tablerow1" runat="server"> <asp:tablecell ID="Tablecell1" runat="server">Customer</asp:TableCell> <asp:tablecell ID="Tablecell2" runat="server">Contact</asp:TableCell> </asp:tablerow> </asp:table> </HeaderTemplate> <ItemTemplate> <asp:table ID="Table2" runat="server"> <asp:tablerow ID="Tablerow2" runat="server" font-bold="true"> <asp:tablecell ID="Tablecell3" runat="server"> <%# Eval("CustomerID") %> </asp:tablecell> <asp:tablecell ID="Tablecell4" runat="server"> <%# Eval("ContactName") %> </asp:tablecell> </asp:tablerow> <asp:tablerow ID="Tablerow3" runat="server"> <asp:tablecell ID="Tablecell5" runat="server" columnspan="2"> <%# Eval("Address") + " - " + Eval("City") %> </asp:tablecell> </asp:tablerow> </asp:table> </ItemTemplate> </asp:datalist> </div> </form> </body> </html>