首页 > Web开发 > 详细

asp控件Repeater运用

时间:2015-11-05 18:45:56      阅读:230      评论:0      收藏:0      [点我收藏+]

双层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();


            }
        }            

 

asp控件Repeater运用

原文:http://www.cnblogs.com/King-JJ/p/4940119.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!