<script language="c#" runat="server">
protected int intCount = 80;//数量
protected int intCategoryID = 43;//分类id
protected int intColumnCount = 4;//列数
protected void Page_Load(object sender, EventArgs e)
{
System.Collections.Generic.IList<TradeSite.Product.Model.ProductInfo> list = TradeSite.Product.BLL.Product.GetByCategoryID(intCategoryID, intCount);
if (list == null)
{
list = new System.Collections.Generic.List<TradeSite.Product.Model.ProductInfo>();
}
RepList.DataSource = list;
RepList.DataBind();
}
public string GetImgUrl(string url)
{
if (url.Length > 0)
{
return TradeSite.Utility.UrlUtility.GetBaseURL() + url;
}
return TradeSite.Utility.UrlUtility.GetBaseURL() + "/images/NoPic.gif";
}
public string GetLinkUrl(int id)
{
return TradeSite.Utility.UrlUtility.GetBaseURL() + "/Product/ProductDetailInfo.aspx?productID=" + id.ToString();
}
public decimal GetProductPrice(int id)
{
TradeSite.Product.Model.ProductInfo info = TradeSite.Product.BLL.Product.GetByID(id);
if (info.ProductBuyType == 1)
{
return info.PBuy1Price;
}
else if (info.ProductBuyType == 2)
{
return info.PBuy2SalePrice;
}
else
{
return info.PBuy3SalePrice;
}
}
</script>
<table>
<tr>
<td>
<table width="80%">
<tr>
<asp:Repeater ID="RepList" runat="server">
<ItemTemplate>
<td>
<a href="<%# GetLinkUrl(Convert.ToInt32(Eval("ID")))%>">
<img src='<%# GetImgUrl(Convert.ToString(Eval("ImageUrl1")))%>' alt="<%#("ProductName") %>"
border="0" width="240" height="240" />
</a></br> <a href="<%# GetLinkUrl(Convert.ToInt32(Eval("ID")))%>" style="text-decoration: none;">
<%#Eval("ProductName") %>
</a>
<br />
<%#GetProductPrice((int)Eval("ID")).ToString() %>
</td>
<asp:Literal ID="Literal2" runat="server" Visible="<%#(Container.ItemIndex+1) % intColumnCount==0 %>"
Text="</tr><tr>"></asp:Literal>
</ItemTemplate>
</asp:Repeater>
</tr>
</table>
</td>
</tr>
</table>
标记成红色的部分是关键代码所在,其他可以忽略不计.