轉:Repeater嵌套綁定Repeater以及內層調用外層資料

來源:互聯網
上載者:User

標籤:style   blog   io   color   ar   sp   資料   div   on   

<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 />                                     父級資料:<%# DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "qtid")%>                                     父級序號:<%# ((RepeaterItem)Container.Parent.Parent).ItemIndex %>                            </ItemTemplate>                        </asp:Repeater>                    </div>                </td>            </tr>        </ItemTemplate>    </asp:Repeater></table>
private void Repeater1Bind()        {//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();            }        }

 

轉:Repeater嵌套綁定Repeater以及內層調用外層資料

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.