<%@ Control Language="JScript" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ OutputCache Duration="3600" VaryByParam="None" %> <script runat="server"> public var ProductID : int ; //******************************************************* // // The Page_Load event on this page is used to obtain // from a database a list of all popular items this // weel and then databind it to an asp:datalist control. // // To optimize performance, this user control is output // cached for a period of 1 hour. // //******************************************************* function Page_Load(sender: Object, e: EventArgs) : void { // Obtain list of favorite items var products : IBuySpy.ProductsDB = new IBuySpy.ProductsDB(); // Databind and display the list of favorite product items productList.DataSource = products.GetMostPopularProductsOfWeek(); productList.DataBind(); // Hide the list if no items are in it if (productList.Items.Count == 0) { productList.Visible = false; } } <table width="95%" cellpadding="0" cellspacing="0" border="0"> <asp:Repeater ID="productList" runat="server"> <HeaderTemplate> <tr> <td class="MostPopularHead"> Our most popular items this week </td> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td bgcolor="#d3d3d3"> <asp:HyperLink class="MostPopularItemText" NavigateUrl='<%# "ProductDetails.aspx?ProductID=" + DataBinder.Eval(Container.DataItem, "ProductID")%>' Text='<%#DataBinder.Eval(Container.DataItem, "ModelName")%>' runat="server" /> <br> </td> </tr> </ItemTemplate> <FooterTemplate> <tr> <td bgcolor="#d3d3d3"> </td> </tr> </FooterTemplate> </asp:Repeater> </table>