zoukankan      html  css  js  c++  java
  • 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>

    玉环人才吧 玉环人才网 玉环人力网 玉环招聘网 三支脚人才网

    玉环人力网(又名玉环人才网)是玉环人才吧旗下一流的玉环人力资源招聘行业服务品牌,汇集海量玉环人才,开放玉环人才简历和玉环岗位,提供玉环招聘网,玉环人才市场动态行情,玉环劳务派遣,玉环培训等,是玉环最大的人才网站。

  • 相关阅读:
    Java面经
    关于MarkDown语法
    JQuery
    Filter & Listener
    JSP & EL & JSTL
    Cookie & Session
    Servlet & HTTP
    Tomcat
    XML
    BootStrap
  • 原文地址:https://www.cnblogs.com/taizhouxiaoba/p/3227597.html
Copyright © 2011-2022 走看看