zoukankan      html  css  js  c++  java
  • 关于Reapeter的总结

    在aspx文件中操作:
    <asp:Repeater ID="ConsultRepeater" runat="server" OnItemDataBound="ConsultRepeater_ItemDataBound">
                  <ItemTemplate>
     <%# Eval("Ucontent")%>
        </ItemTemplate>
     </asp:Repeater>
    1.在对应的cs文件中,获取每项的数据的方法:
     protected void ConsultRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
       {
           if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
           {
               Panel replyPanel = e.Item.FindControl("ReplyPanel") as Panel;//找到里层的repeater对象
    
                DataRowView drv = (DataRowView)e.Item.DataItem; //***
                if (string.IsNullOrEmpty(drv["Response"].ToString()))
                {
                    replyPanel.Visible = false;
                }
                else
                    replyPanel.Visible = true;
           }
       }
    
    2.多个repeater的嵌套使用:
    <asp:Repeater ID="ProductRepeater" runat="server" 
                onitemdatabound="ProductRepeater_ItemDataBound">
                <ItemTemplate>
                    <li>
                        <div class="img">
                            <img src='Prod_Images/<%# Eval("Pro_Small_Image") %>' height="100" width="100" />
                        </div>
                        <div class="text">
                            <div class="title">
                                <a href='coupon.aspx?bigcategory=<%# Eval("Pro_Table")%>&proid=<%# Eval("Pro_ID")%>'>
                                    <%# Eval("Pro_Name")%></a></div>
                            <div>
                                
                                    <asp:Repeater ID="ParamRepeater" runat="server">
                                    <ItemTemplate>
                                        <span><%# Eval("Name")%>: <%# Eval("Value")%></span>
                                    </ItemTemplate>
                                    <AlternatingItemTemplate>
                                        <span class="bar">|</span><span><%# Eval("Name")%>: <%# Eval("Value")%></span>
                                    </AlternatingItemTemplate>
                                    </asp:Repeater>
                            </div>
                            <div class="footer">
                                <a href='coupon.aspx?bigcategory=<%# Eval("Pro_Table")%>&proid=<%# Eval("Pro_ID")%>'>
                                    <asp:Label ID="CityLabel" runat="server" Text=""></asp:Label>共有<span class="digit"><%# Eval("CouponNum")%></span>条优惠</a>
                            </div>
                        </div>
                    </li>
                </ItemTemplate>
            </asp:Repeater>
    对应的cs文件:
    protected void ProductRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //判断里层repeater处于外层repeater的哪个位置( AlternatingItemTemplate,FooterTemplate,
            //HeaderTemplate,,ItemTemplate,SeparatorTemplate)
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("ParamRepeater") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                string str = Convert.ToString(rowv["Pro_Content"]); //获取填充子类的内容
                rep.DataSource = Product.FillPara(str); //LiftQuestionCtr.GetSomeQuestionsByTypeid(typeid, 2);
                rep.DataBind();
            }
            Label cityLable = e.Item.FindControl("CityLabel") as Label;
            cityLable.Text  = CityDA.GetCurCity();
        }
  • 相关阅读:
    iOS版打地鼠游戏源码
    OuNews 简单的新闻客户端应用源码
    安卓DJ113舞曲网应用客户端 项目源码(服务器+客户端)
    博客迁移
    iOS 多张图片保存到相册问题(add multiple images to photo album)
    【转】 iOS 学习之 NSPredicate 模糊、精确、查询
    iOS 设置图片imageView圆角——对图片进行裁剪
    iOS9的那些坑 — — WeiboSDK registerApp启动就崩溃
    关于Debug下的Log打印问题
    Runtime运行时学习(一)
  • 原文地址:https://www.cnblogs.com/me115/p/1825292.html
Copyright © 2011-2022 走看看