2012년 2월 10일 금요일
..:: Learn » 쇼핑몰 프로젝트 » [4] 상품관리 » 14. 연관상품 ::..
최소화(Minimize)연관상품(AlsoBought.ascx)

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AlsoBought.ascx.cs" Inherits="AlsoBoughtControl" %>
<table width="100%" cellpadding="5" cellspacing="0" border="0">
 <tr>
  <td>
   <asp:Repeater ID="alsoBoughtList" runat="server">
    <HeaderTemplate>
     <tr>
      <td class="MostPopularHead">
       연관상품(이미 이 제품을 구입한 고객)
      </td>
     </tr>
    </HeaderTemplate>
    <ItemTemplate>
     <tr>
      <td bgcolor="#d3d3d3">
       &nbsp;
       <asp:HyperLink class="MostPopularItemText" NavigateUrl='<%# "ProductDetails.aspx?ProductID=" + DataBinder.Eval(Container.DataItem, "ProductID")%>' Text='<%#DataBinder.Eval(Container.DataItem, "ModelName")%>' runat="server" ID="Hyperlink1"/>
       <br />
      </td>
     </tr>
    </ItemTemplate>
   </asp:Repeater>
  </td>
 </tr>
</table>

최소화(Minimize)연관상품(AlsoBought.ascx.cs)

using System;

public partial class AlsoBoughtControl : System.Web.UI.UserControl
{
    #region Event Handlers
    protected void Page_Load(object sender, System.EventArgs e)
    {
        ProductsDB productCatalogue = new ProductsDB();

        alsoBoughtList.DataSource = productCatalogue.GetProductsAlsoPurchased(
            Convert.ToInt32(Request["ProductID"]));
        alsoBoughtList.DataBind();

        if (alsoBoughtList.Items.Count == 0)
        {
            alsoBoughtList.Visible = false;
        }
    }
    #endregion
}

Copyright 2000-2011 by DotNetKorea all right reserved.   사용약관  개인정보취급방침