嵌套Gridview上的悬停菜单

时间:2013-10-02 12:06:08

标签: c# javascript asp.net ajax

我有一个Gridview。在里面我有一个嵌套的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>

1 个答案:

答案 0 :(得分:0)

背后的代码是什么样的?

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

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