1

我有一个Repeater 控件,现在想将它添加到Accordion。它似乎不起作用。我该怎么做呢?

我的中继器:

<ajaxToolkit:Accordion ID="accordion1" runat="server" CssClass="accordion" HeaderCssClass="accordionHeader"
    HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent"
    AutoSize="None" FadeTransitions="true" TransitionDuration="250" FramesPerSecond="40"
    RequireOpenedPane="false" SuppressHeaderPostbacks="true">
        <Panes>
            <asp:Repeater ID="Repeater1" runat="server"  DataSourceID="SchemeDataSource1">
                <ItemTemplate>
                    <table style="border: thin solid #000000;color: Black;background-color:#E0E0E0"; width: "100%" >
                            <tr>
                                <td>
                                    <ajaxToolkit:AccordionPane ID="AccordionPane1" runat="server">
                                        <Header>
                                            PRENO
                                            <asp:Label ID="lblPreno" runat="server" Text='<%# Bind("PRENR") %>'></asp:Label>
                                            MONTHLY PREMIUM
                                            <asp:Label ID="lblPrem" runat="server" Text='<%# Bind("PREMIUM") %>'></asp:Label>
                                            <br />
                                            <asp:LinkButton ID="lnkPre" runat="server" ToolTip="Copy Premium To New Scheme" Font-Bold="True"
                                                Font-Size="Larger" Visible="true">>>
                                            </asp:LinkButton>
                                            <br />
                                            Relation: [
                                            <asp:Label ID="lblRel" runat="server" Text='<%# Bind("RELATION") %>'></asp:Label>
                                            ] UWCODE: [
                                            <asp:Label ID="lblUw" runat="server" Text='<%# Bind("UWFEECODE") %>'></asp:Label>
                                            ][
                                            <asp:Label ID="lblUwDescription" runat="server" Text='<%# Bind("DESCRIPTION") %>'></asp:Label>
                                            ]
                                            <br />
                                        </Header>
                                        <Content>
                                            <table>
                                                <tr align="left" valign="top">
                                                    <td align="left">
                                                        <asp:DetailsView ID="dvEarner" runat="server" HeaderText="NO EARNER" EmptyDataText="No Results To Display"
                                                            HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px"
                                                            BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
                                                            CellPadding="3" CellSpacing="2" EnableViewState="False">
                                                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                                            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                                                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                        </asp:DetailsView>
                                                    </td>
                                                    <td align="left">
                                                        <asp:DetailsView ID="dvJVName" runat="server" HeaderText="JV NAME" HeaderStyle-BorderColor="Black"
                                                            HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px" EmptyDataText="JV NAME"
                                                            AlternatingRowStyle-BorderStyle="Solid" AlternatingRowStyle-BorderWidth="1px"
                                                            BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
                                                            CellPadding="3" CellSpacing="2">
                                                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                                            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                                                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                            <EmptyDataRowStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="true" />
                                                        </asp:DetailsView>
                                                    </td>
                                                    <td align="left">
                                                        <asp:DetailsView ID="DetailsView1" runat="server" HeaderText="%" HeaderStyle-BorderColor="Black"
                                                            HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px" EmptyDataText="%"
                                                            AlternatingRowStyle-BorderStyle="Solid" AlternatingRowStyle-BorderWidth="1px"
                                                            BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
                                                            CellPadding="3" CellSpacing="2">
                                                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                                            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                                                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                            <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
                                                            <EmptyDataRowStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="true" />
                                                        </asp:DetailsView>
                                                    </td>
                                                    <td align="left">
                                                        <asp:DetailsView ID="dvProduct" runat="server" HeaderText="PRODUCT DETAILS" HeaderStyle-BorderColor="Black"
                                                            HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px" EmptyDataText="No Results To Display"
                                                            AlternatingRowStyle-BorderStyle="Solid" AlternatingRowStyle-BorderWidth="1px"
                                                            BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
                                                            CellPadding="3" CellSpacing="2">
                                                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                                            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                                                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                        </asp:DetailsView>
                                                    </td>
                                                    <td align="left">
                                                        <asp:DetailsView ID="dvFeeDetails" runat="server" HeaderText="ADDITIONAL FEE DETAILS"
                                                            HeaderStyle-BorderColor="Black" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1px"
                                                            EmptyDataText="No Results To Display" AlternatingRowStyle-BorderStyle="Solid"
                                                            AlternatingRowStyle-BorderWidth="1px" BackColor="#DEBA84" BorderColor="#DEBA84"
                                                            BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2">
                                                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                                            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                                                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                        </asp:DetailsView>
                                                        <br />
                                                    </td>
                                                </tr>
                                            </table>
                                            <table>
                                                <tr>
                                                    <td>
                                                        <strong><u>UNDERWRITER DETAILS:</u></strong>
                                                        <asp:GridView ID="grdUWDetails" runat="server" ForeColor="#333333" CellPadding="4"
                                                            AutoGenerateSelectButton="False">
                                                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                                            <EmptyDataTemplate>
                                                                No results to display.</EmptyDataTemplate>
                                                        </asp:GridView>
                                                        <br />
                                                        <hr />
                                                    </td>
                                                </tr>
                                            </table>
                                        </Content>
                                    </ajaxToolkit:AccordionPane>
                                </td>
                            </tr>                                                  
                        </table>
                </ItemTemplate>
            </asp:Repeater>
        </Panes>
    </ajaxToolkit:Accordion>

中继器项目绑定:

Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
  Dim strPreno As String = DirectCast(e.Item.FindControl("lblPreno"), Label).Text

  Dim dv As DetailsView = DirectCast(e.Item.FindControl("dvEarner"), DetailsView)
  dv.DataSource = fnLoadPremiums(strPreno)
  dv.DataBind()

  Dim dv1 As DetailsView = DirectCast(e.Item.FindControl("dvProduct"), DetailsView)
  dv1.DataSource = fnLoadProduct(strPreno)
  dv1.DataBind()

  Dim dv2 As DetailsView = DirectCast(e.Item.FindControl("dvFeeDetails"), DetailsView)
  dv2.DataSource = fnLoadFeeDetails(strPreno)
  dv2.DataBind()

  Dim grd As GridView = DirectCast(e.Item.FindControl("grdUWDetails"), GridView)

  grd.DataSource = fnLoadGrid(strPreno)
  grd.DataBind()
End If
End Sub
4

1 回答 1

1

解决这个问题的唯一方法是动态添加我的 Accordion 并通过后面的代码添加 AccordionPanes。

HTML:

<ajaxToolkit:Accordion ID="MainAccordion1" runat="server" CssClass="accordion" HeaderCssClass="accordionHeader"
        HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent"
        AutoSize="None" FadeTransitions="true" TransitionDuration="250" FramesPerSecond="40"
        RequireOpenedPane="false" SuppressHeaderPostbacks="true">
        <Panes>

        </Panes>
</ajaxToolkit:Accordion>

代码背后:

'Create AccrionPane
Dim pane As New AjaxControlToolkit.AccordionPane
pane.ID = "pane" & i
pane.HeaderContainer.Controls.Add(headerLabel1)
pane.HeaderContainer.Controls.Add(headerLabel2)

Me.MainAccordion1.Panes.Add(pane)

我遍历我的数据源并在我的 Accrordion 中填充数据

于 2013-02-27T12:30:49.860 回答