zoukankan      html  css  js  c++  java
  • 在Repeater中嵌套使用Repeater

    前台页面部分:
    <asp:Repeater id="rptCategories" runat="server">
      <HeaderTemplate>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
      </HeaderTemplate>
      <ItemTemplate>
        <!--分类名称-->
        <tr><th><%# DataBinder.Eval(Container.DataItem, "TypeName") %></th></tr>
        <!--分类下的产品-->
        <asp:Repeater id="rptProduct" runat="server">
          <ItemTemplate>
            <tr><td><a href='ProductInfo.aspx?Id=<%# DataBinder.Eval(Container.DataItem, "ID") %>'><%# DataBinder.Eval(Container.DataItem, "ProductName") %></a></td></tr>
          </ItemTemplate>
        </asp:Repeater>
      </ItemTemplate>
      <FooterTemplate>
        </table>
      </FooterTemplate>
    </asp:Repeater>

    后台代码部分(部分代码):
    //在绑定分类品名时,绑定分类下的产品
    private void rptCategories_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
    {
        BLL.Products products =new BLL.Products();
        if (e.Item.ItemType == ListItemType.Item ||    e.Item.ItemType == ListItemType.AlternatingItem) 
        {
            Repeater rptProduct = (Repeater) e.Item.FindControl("rptProduct");
            //找到分类Repeater关联的数据项
            DataRowView rowv = (DataRowView)e.Item.DataItem;
            //提取分类ID
            int CategorieId = Convert.ToInt32(rowv["ID"]);
            //根据分类ID查询该分类下的产品,并绑定产品Repeater
            rptProduct.DataSource = products.GetProductsByCategorieId(CategorieId);
            rptProduct.DataBind();
        }
    }
  • 相关阅读:
    Expression Blend实例中文教程(13)
    Expression Blend实例中文教程(12)
    Expression Blend实例中文教程(11)
    【转】Python3中urllib详细使用方法(header,代理,超时,认证,异常处理)
    cookie
    【转】cookielib模块
    代理的步骤
    urllib.parse.urlencode
    urllib.request.Request
    【转】python3 urllib.request 网络请求操作
  • 原文地址:https://www.cnblogs.com/colder/p/1723103.html
Copyright © 2011-2022 走看看