zoukankan      html  css  js  c++  java
  • Repeater嵌套Repeater的结构

    Repeater嵌套Repeater的结构:一般写过的都能看懂吧

     cs代码: 


    private void RpTypeBind()
            {//GetQuestionTypeAndCount() 返回一个datatable
                this.rptypelist.DataSource = LiftQuestionCtr.GetQuestionTypeAndCount();                   
                this.rptypelist.DataBind();
            }
                   protected void rptypelist_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("rpquestionlist") as Repeater;//找到里层的repeater对象
                    DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                    int typeid = Convert.ToInt32(rowv["qtid"]); //获取填充子类的id 
                    rep.DataSource = LiftQuestionCtr.GetSomeQuestionsByTypeid(typeid, 2);
                    rep.DataBind();
                }
            }

    aspx:


    <table border="0" cellpadding="0" cellspacing="0" style="margin-bottom: 5px" width="100%">
        <asp:Repeater runat="server" ID="rptypelist" OnItemDataBound="rptypelist_ItemDataBound">
            <ItemTemplate>
                <tr>
                    <td class="fb">
                        &nbsp;&nbsp;<a href="Lists.aspx?Qtid=<%#Eval("qtid") %>"><%#Eval("qtypename") %></a> <span id="askCount_15"
                            class="date2">[<%#Eval("typecount")%>]</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div id="askTop2_15" class="ask_list">
                            <asp:Repeater runat="server" ID="rpquestionlist">
                                <ItemTemplate>
                                    <a href="Question.aspx?qid=<%#Eval("liftquestionid")%>">
                                        <%#Eval("questiontitle")%></a><br />
                                </ItemTemplate>
                            </asp:Repeater>
                        </div>
                    </td>
                </tr>
            </ItemTemplate>
        </asp:Repeater>
    </table>
  • 相关阅读:
    卸载全部appx应用(包括应用商店)
    重置 Launchpad 和更新APP图标缓存
    删除OSX中第三方的「偏好设置」程序(.prefPane)
    IOS segue(跳转页面处理)
    IOS NSNotificationCenter(通知 的使用)监听文本框的文字改变
    IOS UITextFieldDelegate (常用的代理方法)
    IOS UIActionSheet(底部 弹出框的使用)
    IOS 偏好设置数据 存 取(Preferences文件夹)
    IOS plist的数据 存 取(沙河目录)
    显示 Mac隐藏的文件夹 命令语句
  • 原文地址:https://www.cnblogs.com/jj123/p/13427192.html
Copyright © 2011-2022 走看看