简体   繁体   中英

Creating a repeater dynamically inside an accordion pane

My goal is to nest a Repeater inside an ASP.Net AJAX Accordion 's AccordionPane .

So there is one Accordion which I am programmatically adding AccordionPanes to. The amount of panes I add depends on my particular dataset's count value, usually no more than 5. I've managed to do this successfully.

The thing I am having difficulty with is creating and adding a Repeater per each AccordionPane.

I've glanced over http://iridescence.no/post/Using-Templated-Controls-Programmatically.aspx but this is not exactly what I had in mind. Instead, I would rather declare a single Repeater as static HTML that I could then "clone" when I need. How can I achieve this? Obviously I would want each control's ID (within this declared Repeater) to be generated automatically each time i "clone" it.

The repeater looks like this:

<asp:Repeater ID="rptForum" runat="server">
    <ItemTemplate>
        <div runat="server" style="border:solid #d3d3d3 1px; border-bottom-width:0px;">
            <table width="100%">
                <tr><td align="left">
                    <asp:Label runat="server" Font-Size="12px" />
                </td></tr>
                <tr><td align="left">
                    >>&nbsp;<asp:Label runat="server" Font-Size="12px" Text='<%# Eval("query") %>' />
                </td></tr>
            </table>
        </div>
    </ItemTemplate>
</asp:Repeater>

I might add more fields to be databound as I progress.

Any ideas appreciated..

You should be able to do that by adding the repeater to the Content template:

<cc1:AccordionPane ID="AccordionPane1" runat="server">
    <Header>
        Foo
    </Header>    
    <Content>
        <asp:Repeater ID="Repeater1" runat="server" ...>
            ...
        </asp:Repeater>
    </Content>
</cc1:AccordionPane>

您可以使用手风琴进行分层数据绑定,如下所示: http : //aspalliance.com/1674_complex_data_binding_with_the_accordion_control

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM