zoukankan      html  css  js  c++  java
  • asp控件Repeater运用

    双层repeater嵌套

                    <asp:Repeater ID="rpt_dataRepeatgroup" runat="server" OnItemDataBound="rpt_dataRepeatgroup_ItemDataBound">
                        <HeaderTemplate>
                            
                        </HeaderTemplate>
                        <ItemTemplate>
                            <h3 class="font14 tie_bor " ><b><%# DataBinder.Eval(Container.DataItem,"Name") %></b></h3>
                            <ul class="con_list font12 clearfix" >
                                <asp:Repeater ID="rpt_dataRepeatInfo" runat="server">
                                    <ItemTemplate>
                                        <li class="w1 color_blue"><%# DataBinder.Eval(Container.DataItem,"InfoName") %></li>
                                        <li class="w2 color_9"><%# Eval("Tel") %></li>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </ul>
                           
                        </ItemTemplate>
                        <FooterTemplate>
                        </FooterTemplate>
                    </asp:Repeater>

    后台代码

    public void initdatas()
    {
        List<Entity.CTS_Group> lstcg=new List<Entity.CTS_Group>();
        rpt_dataRepeatgroup.DataSource = lstcg;
        rpt_dataRepeatgroup.DataBind();
    }
            protected void rpt_dataRepeatgroup_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    Repeater rep = e.Item.FindControl("rpt_dataRepeatInfo") as Repeater;
                    SHHYPortal.Entity.CTS_Group rowv = (SHHYPortal.Entity.CTS_Group)e.Item.DataItem;
                    Guid groupID = rowv.ID;//用于内嵌repeater条件查询
    
                    
                   ContactInfoService cis = new ContactInfoService();
            List<Entity.CTS_Info> lstcg = cis.GetAll(a => a.GroupID == groupID).ToList();
                    rep.DataSource = lstcg;
                    rep.DataBind();
    
    
                }
            }            
  • 相关阅读:
    HDU 5319 Painter
    HDU 5328 Problem Killer
    HDU 5327 Olympiad
    HDU 5339 Untitled
    HDU 5335 Walk Out
    HDU 5317 RGCDQ
    HDU 5326 Work
    CF GYM 100703A Tea-drinking
    CF GYM 100703B Energy Saving
    CF GYM 100703F Game of words
  • 原文地址:https://www.cnblogs.com/King-JJ/p/4940119.html
Copyright © 2011-2022 走看看