zoukankan      html  css  js  c++  java
  • Repeater嵌套绑定

    页面

     <div class="list1">
                    <asp:Repeater ID="rptlist" runat="server" OnItemDataBound="rptlist_ItemDataBound">
                        <ItemTemplate>
                            <div class="titlebox">
                                <div class="title">
                                    <h1><%# Eval("title") %></h1>
                                </div>
                                <ul>
                                    <asp:Repeater ID="rptItem" runat="server">
                                        <ItemTemplate>
                                            <li><a href='/roomShow.aspx?cid=<%#Eval("roomid") %>'><%# Eval("title") %></a></li>
    
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            <div class="clear"></div>
                                        </FooterTemplate>
                                    </asp:Repeater>
                                </ul>
                            </div>
                        </ItemTemplate>
    
                    </asp:Repeater>
    
                </div>
    View Code

    .cs文件

         protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
    
                    DataSet ds = new BLL.rooms().GetList("parentid=0");
                    DataTable dt = ds.Tables[0];
    
                    this.rptlist.DataSource = ds.Tables[0];
                    this.rptlist.DataBind();
                }
            }
    
            protected void rptlist_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    Repeater rep = e.Item.FindControl("rptItem") as Repeater;//找到里层的repeater对象
                    DataRowView rowv = (DataRowView)e.Item.DataItem;
                    String pid = rowv["roomid"].ToString();
    
                 
                    DataSet ds = new BLL.rooms().GetList(" parentid=" + pid);
                    rep.DataSource = ds.Tables[0];
                    rep.DataBind();
                }
            }
    View Code
  • 相关阅读:
    UU跑腿
    Java基础之接口与抽象类的区别
    经典面试题:Redis为什么这么快?
    isBlank与isEmpty
    阅读联机API文档
    从文本中取出链接地址 并检测链接地址能否打开
    2019-01-19=树莓派学习总结
    单片机知识点
    Linux 编程题
    嵌入式基础知识
  • 原文地址:https://www.cnblogs.com/chenlihong-886/p/11532699.html
Copyright © 2011-2022 走看看