0

我有一个网格视图。在里面我有一个嵌套的 Gridview。我正在使用 javascript 来展开折叠。我的问题是,当我尝试在嵌套的 gridview 上添加 ajax 悬停菜单扩展器时,悬停不显示。我的代码:

<script type="text/javascript">
    $("[src*=plus]").live("click", function () {
        $(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>")
        $(this).attr("src", "../minusbutton.png");
    });
    $("[src*=minus]").live("click", function () {
        $(this).attr("src", "../plusbutton.png");
        $(this).closest("tr").next().remove();
    });
</script>

<asp:GridView ID="GridViewCustomers" runat="server" AllowPaging="True" 
                AutoGenerateColumns="False"  DataKeyNames="CustomerID">
    <Columns>
        <asp:TemplateField HeaderText="CustomerID" InsertVisible="False" 
                            SortExpression="lblCustomerID" Visible="False">
            <ItemTemplate>
                <asp:Label ID="lblCustomerID" runat="server" 
                            Text='<%# Bind("CustomerID") %>'>
                </asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Name"  
                            SortExpression="Name" >
            <ItemTemplate>
                <asp:Label ID="Name" runat="server" Text='<%# Bind("Name") %>'>
                </asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField>
            <ItemTemplate>
                <img alt = "" style="cursor: pointer" src="../plusbutton.png" />
                <asp:Panel ID="pnlCustomersDetails" runat="server" Style="display: none">
                    <asp:GridView ID="mynestedGridView"  runat="server" 
                                AutoGenerateColumns="False"
                                DataKeyNames="DetailsID">

                        <Columns>
                            <asp:TemplateField Visible="false" HeaderText="DetailsID">
                                <ItemTemplate>
                                    <asp:Label ID="lblDetailsID"   runat="server" Text='<%# Bind("DetailsID") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Details>
                                <ItemTemplate>
                                    <asp:Label ID="lblDetails"  runat="server" Text='<%# Bind("Details") %>'></asp:Label>
                                    <br />
                                    <asp:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="lblDetails" PopupControlID="Panel2" PopupPosition="Center" OffsetX="0" OffsetY="0" PopDelay="50">
                                    </asp:HoverMenuExtender>
                                    <asp:Panel ID="Panel2" runat="server">
                                        <asp:Button ID="Button1"  runat="server" Text="Button"></asp:Button>
                                    </asp:Panel>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </asp:Panel>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
4

1 回答 1

0

后面的代码是什么样子的?

在处理嵌套的 gridview 元素时,我发现本教程非常有用:

http://www.aspsnippets.com/Articles/ASPNet-Nested-GridViews-GridView-inside-GridView-with-Expand-and-Collapse-feature.aspx

于 2013-10-10T12:44:27.713 回答