Hi,
i used this demo (http://aspsnippets.com/Articles/Collapsible-Nested-GridView-with-Paging-using-ASPNet.aspx) to achieve the multi-nested gridview.
On Clicking on the Plus image of the Parent-Level it works like in the example. The Child Gridview was added in a new row.
Now I have on more nested Gridview inside. When I Click on the Plus image of the Child Gridview, no new HTML row was added with the jQuery script. Therefore the GridView is inserted in the first Column of the row.
The Code for my multi nested Gridview:
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false" CssClass="Grid"
DataKeyNames="CustomerID"> <Columns>
<asp:TemplateField> <ItemTemplate>
<asp:ImageButton ID="imgShow" runat="server" OnClick="Show_Hide_ChildGrid1" ImageUrl="~/images/plus.png"
CommandArgument="Show" />
<asp:Panel ID="pnlOrders1" runat="server" Visible="false" Style="position: relative">
<asp:GridView ID="gvCustomers1" runat="server" AutoGenerateColumns="false" CssClass="Grid"
DataKeyNames="CustomerID">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="imgShow" runat="server" OnClick="Show_Hide_ChildGrid" ImageUrl="~/images/plus.png"
CommandArgument="Show" />
<asp:Panel ID="pnlOrders" runat="server" Visible="false" Style="position: relative">
<asp:GridView ID="gvOrders" runat="server" AutoGenerateColumns="false" PageSize="5"
AllowPaging="true" OnPageIndexChanging="OnChildGrid_PageIndexChanging" CssClass="ChildGrid">
<Columns>
<asp:BoundField ItemStyle-Width="150px" DataField="OrderId" HeaderText="Order Id" />
<asp:BoundField ItemStyle-Width="150px" DataField="OrderDate" HeaderText="Date" />
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="150px" DataField="ContactName" HeaderText="Contact Name" />
<asp:BoundField ItemStyle-Width="150px" DataField="City" HeaderText="City" />
</Columns>
</asp:GridView>
</asp:Panel> </ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="150px" DataField="ContactName" HeaderText="Contact Name" />
<asp:BoundField ItemStyle-Width="150px" DataField="City" HeaderText="City" />
</Columns> </asp:GridView>
I also added this onClick event to the example:
protected void Show_Hide_ChildGrid1(object sender, EventArgs e) {
ImageButton imgShowHide = (sender as ImageButton);
GridViewRow row = (imgShowHide.NamingContainer as GridViewRow);
if (imgShowHide.CommandArgument == "Show") {
row.FindControl("pnlOrders1").Visible = true;
imgShowHide.CommandArgument = "Hide";
imgShowHide.ImageUrl = "~/images/minus.png";
GridView gvCustomers1 = row.FindControl("gvCustomers1") as GridView; //gvOrders.ToolTip = customerId;
gvCustomers1.DataSource = GetData("select top 10 * from Customers");
gvCustomers1.DataBind(); } else {
row.FindControl("pnlOrders1").Visible = false;
imgShowHide.CommandArgument = "Show";
imgShowHide.ImageUrl = "~/images/plus.png"; } }
Any Ideas why no new row is added in Childgrid?