zoukankan      html  css  js  c++  java
  • Repeater双层嵌套

    前台代码:

     <div>
            <asp:Repeater ID="rptOne" runat="server" OnItemDataBound="rptOne_ItemDataBound" >
                <ItemTemplate>
                    <div >
                        <%# Eval("DepartName") %>
                        <div>
                            <asp:Repeater ID="rptTwo" runat="server">
                                <ItemTemplate>
                                    <%# Eval("StaffName") %>
                                </ItemTemplate>
                            </asp:Repeater>
                        </div>
                    </div>
                </ItemTemplate>
            </asp:Repeater>
        </div>
    

    后台代码:

    public partial class WebForm1 : System.Web.UI.Page
        {
            StaffInfoBLL sbll = new StaffInfoBLL();
            DepartmentInfoBLL dbll = new DepartmentInfoBLL();
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    this.rptOne.DataSource = dbll.GetAll();
                    Session["DepartAll"] = sbll.GetAll();
                    this.rptOne.DataBind();
                }
            }
    
            protected void rptOne_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    Repeater rptWo = e.Item.FindControl("rptTwo") as Repeater;
                    DepartmentInfo d = e.Item.DataItem as DepartmentInfo;
                    IList<StaffInfo> list = Session["DepartAll"] as IList<StaffInfo>;
                    if (list != null)
                    {
                        rptWo.DataSource = list.Where(p=>p.DepartmentInfo.DepartId==d.DepartId);
                        rptWo.DataBind();
                    }
                }
            }
        }
    

      

  • 相关阅读:
    uva 1605 building for UN ——yhx
    uva 120 stacks of flapjacks ——yhx
    uva133-S.B.S.
    Uva10082 WERTYU -S.B.S.
    Quicksum-S.B.S.
    NOIP2014提高组 DAY1 -SilverN
    NOIP2013普及组 -SilverN
    uva 1354 Mobile Computing ——yhx
    UVa 11292 Dragon of Loowater
    UVa 839 Not so Mobile
  • 原文地址:https://www.cnblogs.com/liujie1111/p/3648432.html
Copyright © 2011-2022 走看看