asp.net中repeater记录的换行解决方案

<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>

 

标记成红色的部分是关键代码所在,其他可以忽略不计.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值