在手风琴窗格内动态创建转发器

发布于 2024-12-10 14:19:22 字数 1318 浏览 2 评论 0原文

我的目标是将 Repeater 嵌套在 ASP.Net AJAX AccordionAccordionPane 中。

因此,我以编程方式向一个 Accordion 添加 AccordionPanes。我添加的窗格数量取决于我的特定数据集的计数值,通常不超过 5。我已经成功地做到了这一点。

我遇到的困难是为每个 AccordionPane 创建并添加一个中继器。

我浏览过 http://iridescent.no/post/Using-Templated- Controls-Programmatically.aspx 但这并不完全是我想要的。相反,我宁愿将单个 Repeater 声明为静态 HTML,然后在需要时可以“克隆”它。我怎样才能实现这个目标?显然,我希望每次“克隆”每个控件的 ID(在此声明的中继器内)时自动生成。

中继器看起来像这样:

<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>

随着我的进展,我可能会添加更多要进行数据绑定的字段。

任何想法表示赞赏..

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">
                    >> <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..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

〗斷ホ乔殘χμё〖 2024-12-17 14:19:22

您应该能够通过将转发器添加到 Content 模板来做到这一点:

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

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>
楠木可依 2024-12-17 14:19:22

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

You can do a hierarchical data bind with the accordion, as illustrated here: http://aspalliance.com/1674_complex_data_binding_with_the_accordion_control

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文