两个Repeater嵌套使用「建议收藏」

两个Repeater嵌套使用「建议收藏」在C#中有时存在着两个嵌套循环的存在,此时可以使用两个Repeater进行循环获取到。    例如:aspx页面中:                                                                                                          ‘alt=””>           

大家好,又见面了,我是你们的朋友全栈君。

C#中有时存在着两个嵌套循环的存在,此时可以使用两个Repeater进行循环获取到。

    例如:

aspx页面中:

  <asp:Repeater ID=”IndexServiceImgs” runat=”server” OnItemDataBound=”RptAllOnItemDataBound22″>

                    <ItemTemplate>

                        <div class=”product”>

                            <a class=”bg_img” href=”#”>

                                <img src='<%#Eval(“cSerImg”) %>’ alt=””></a>

                            <div class=”look”>

                                <a href=”#”>

                                    <div class=”lf”>

                                        <img src=”images/look.png” alt=””>

                                    </div>

                                    <div class=”rf”>

                                        <p>面部护肤热销排行榜</p>

                                        <p><span>点击查看</span>>></p>

                                    </div>

                                </a>

                            </div>

                            <div class=”show”>

                                <ul>

 

                                    <asp:Repeater ID=”IndexGoodsImgs” runat=”server” OnItemDataBound=”RptAllOnItemDataBound11″>

                                        <ItemTemplate>

                                            <li>

                                                <div class=”lf”>

                                                    <a href=”#”>

                                                        <asp:Image ID=”goodsImg” runat=”server” />

                                                    </a>

                                                </div>

                                                <div class=”rf”>

                                                    <a href=”#”><asp:Label ID=”goodsName” runat=”server”></asp:Label></a>

                                                    <a href=”#” class=”into”>立即进入</a>

                                                </div>

                                            </li>

 

                                        </ItemTemplate>

                                    </asp:Repeater>

 

 

                                </ul>

                            </div>

                        </div>

                    </ItemTemplate>

                </asp:Repeater>

  很明显的是,此时在页面布局中是存在着两个Repeater存在的。

    aspx.cs页面中:

    #region 初始化页面

        public void initData()

        {

            string userPhone = “”;

            try

            {

                //string phone = Session[“userPhone”].ToString();

                //if (phone!=null && phone.Length==0)

                //{

                //    Helper.Result(this,”!!!!!“);

                //    return;

                //}

                //else

                //{

                //userPhone = phone;

                //根据用户手机号获取用户待付订单(这里的手机号是写死的 ,注意要改)

                //Index页面中最上面滚动图片从数据库中获取

                DataSet daifukuanSet = FuWuOtoWeiHelper.GetSysIndexBigTupians();

                if (daifukuanSet.Tables[0].Rows.Count > 0)

                {

                    this.IndexBigTupianRepeater.DataSource = daifukuanSet;

                    this.IndexBigTupianRepeater.DataBind();

                }

 

                //获取服务中的大图片

                DataSet IndexServiceSet = FuWuOtoWeiHelper.GetSysIndexServicesTupians();

                if (IndexServiceSet.Tables[0].Rows.Count > 0)

                {

                    this.IndexServiceImgs.DataSource = IndexServiceSet;

                    this.IndexServiceImgs.DataBind();

                }

 

             

 

                //}

            }

            catch (Exception e)

            {

                throw e;

            }

        }

        #endregion

 

        //该方法是服务图片

        protected void RptAllOnItemDataBound22(object sender, RepeaterItemEventArgs e)

        {

            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))

            {

                //string classname = ((Button)e.Item.FindControl(“gDel”)).Text;

                DataRowView drv = (DataRowView)e.Item.DataItem;

                Repeater rptProductList = (Repeater)e.Item.FindControl(“IndexGoodsImgs”);

                //获取具体商品中的图片

                DataSet IndexGoodsSet = FuWuOtoWeiHelper.GetSysIndexGoodsTupians();

                if (IndexGoodsSet.Tables[0].Rows.Count > 0)

                {

                    rptProductList.DataSource = IndexGoodsSet;

                    rptProductList.DataBind();

                }

            }

        }

 

        //该方法是商品展示信息

        protected void RptAllOnItemDataBound11(object sender, RepeaterItemEventArgs e)

        {

            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))

            {

                //string classname = ((Button)e.Item.FindControl(“gDel”)).Text;

                DataRowView drv = (DataRowView)e.Item.DataItem;

                Image image = (Image)e.Item.FindControl(“goodsImg”);

                image.ImageUrl = drv[“cContentImg”].ToString();

                Label label = (Label)e.Item.FindControl(“goodsName”);

                label.Text = drv[“cContentName”].ToString();

            }

        }

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/159101.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 计算机-底层-1

    计算机-底层-1

    2021年5月18日
    110
  • 数组转集合 集合转数组「建议收藏」

    数组转集合 集合转数组「建议收藏」//数组转集合   //数组转集合虽然不能增加减少但可以使用其他集合的方法 比如包含   publicstaticvoidmain(String[]args){   //demo1();  //int[]arr={11,22,33,44,55};  //Listlist=Arrays.asList(arr);基本数据类型的数组转换成集合,会

    2022年6月16日
    28
  • vue查看版本号「建议收藏」

    vue查看版本号「建议收藏」vue-V或者是vue–version查询的是vue-cli的版本,也就是vue脚手架的版本,如果想要查看vue的版本,直接去项目中,找到package.json文件夹找”dependencies”然后就可以看到你装的vue的版本了”dependencies”:{“axios”:”^0.21.1″,”core-js”:”^3.6.5″,”element-ui”:”^2.14.1″,”vue”:”^2.6.11″,”vue-resource”:”^

    2022年5月29日
    301
  • 最全化妆品清单_产品标准清单

    最全化妆品清单_产品标准清单linuxeBPF是3.17内核开始引入的一个全新设计,代码目录主要在kernel/bpf下,它的全称是extendedBPF(eBPF),目前关于eBPF的资料还比较乱,很难得看到一篇对ebpf总结的那么全的文章,转载自此:

    2022年9月21日
    2
  • 中专计算机应用专业简历模板,2016计算机应用专业个人简历模板「建议收藏」

    中专计算机应用专业简历模板,2016计算机应用专业个人简历模板「建议收藏」《2016计算机应用专业个人简历模板》由会员分享,可在线阅读,更多相关《2016计算机应用专业个人简历模板(7页珍藏版)》请在人人文库网上搜索。1、2016计算机应用专业个人简历模板随着互联网的发展与普遍,互联网行业的专业人才颇受欢迎,其就业率也十分可观,下面是fwdq为大家搜集整理的计算机应用应届生个人简历,欢迎阅读。计算机应用专业个人简历模板(一)姓名:目前所在:广…

    2022年5月9日
    38
  • idea最新激活码2022【2022最新】2022.02.07「建议收藏」

    (idea最新激活码2022)好多小伙伴总是说激活码老是失效,太麻烦,关注/收藏全栈君太难教程,2021永久激活的方法等着你。IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html4KDDGND3CI-eyJsaWNlbnNlSW…

    2022年4月1日
    142

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号