.Net绑定双层Repeater

本文详细介绍了 ASP.NET 中 Repeater 控件的使用方法,包括如何通过 Repeater 绑定数据源并进行嵌套显示,以及如何利用 OnItemDataBound 事件处理内层 Repeater 在不同位置的数据绑定。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

                <asp:Repeater ID="rptTitlelist" runat="server" OnItemDataBound="rptTitlelist_OnItemDataBound">
                    <ItemTemplate>
                        <tr>
                            <td colspan="2" class="tabledata" style="font-size: 18px;">
                                <strong>
                                    <%#Eval("Name")%></strong>
                            </td>
                        </tr>
                        <asp:Repeater ID="rptQuestionList" runat="server">
                            <ItemTemplate>
                                <tr>
                                    <td class="tabledata">
                                        <a href="javascript:void(0)" onclick="onClickTab('1',167,this)" title="上传文件">
                                            <%# Container.ItemIndex + 1%>、<%#Eval("CategoryName")%></a>
                                    </td>
                                    <td class="tabledata">
                                        <a id="get_id_<%#Eval("PKID")%>" href="javascript:;" onclick="LayerOpen(<%#Eval("PKID")%>,'<%#Eval("CategoryName") %>');"
                                            style="white-space: nowrap;">上传文件</a>
                                    </td>
                                </tr>
                            </ItemTemplate>
                        </asp:Repeater>
                    </ItemTemplate>
                </asp:Repeater>


        #region 绑定提交资料信息
        /// <summary>
        ///  绑定提交资料信息
        /// </summary>
        private void RptTitleBind()
        {
            // 上传文件列表
            rpApplicationFileList.DataSource = new BLL.ApplicationFileSet().GetApplicationFileList(appId);
            rpApplicationFileList.DataBind();
            rptTitlelist.DataSource = new BLL.AppFileCategory().GetAppFileCategoryList(standardTypeId);
            rptTitlelist.DataBind();
        }

        // 判断里层repeater处于外层repeater的哪个位置
        protected void rptTitlelist_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rptQuestionList") as Repeater;
                DataRowView rowv = (DataRowView)e.Item.DataItem;
                int categoryId = Utils.StrToInt(rowv["PKID"].ToString(), 0);
                rep.DataSource = new BLL.ApplicationFileSet().GetApplicationFileSetID(categoryId, standardTypeId);
                rep.DataBind();
            }
        }
        #endregion

转载于:https://www.cnblogs.com/ment/p/7642388.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值