简体   繁体   English

在手风琴窗格内动态创建中继器

[英]Creating a repeater dynamically inside an accordion pane

My goal is to nest a Repeater inside an ASP.Net AJAX Accordion 's AccordionPane . 我的目标是在ASP.Net AJAX AccordionAccordionPane嵌套一个Repeater

So there is one Accordion which I am programmatically adding AccordionPanes to. 因此,我要以编程方式向其中添加一个AccordionPanes。 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. 我添加的窗格数量取决于特定数据集的计数值,通常不超过5。我已经成功地做到了这一点。

The thing I am having difficulty with is creating and adding a Repeater per each AccordionPane. 我遇到的困难是为每个AccordionPane创建并添加一个Repeater。

I've glanced over http://iridescence.no/post/Using-Templated-Controls-Programmatically.aspx but this is not exactly what I had in mind. 我浏览了http://iridescence.no/post/Using-Templated-Controls-Programmatically.aspx,但这与我的想法不完全相同。 Instead, I would rather declare a single Repeater as static HTML that I could then "clone" when I need. 相反,我宁愿将单个Repeater声明为静态HTML,然后在需要时可以“克隆”。 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. 显然,我希望每次我“克隆”它时都自动生成每个控件的ID(在此声明的Repeater中)。

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: 您应该能够通过将转发器添加到Content模板来做到这一点:

<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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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