Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
JavaScript
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript" language="javascript">

        function divexpandcollapse(divname) {
            var div = document.getElementById(divname);
            var img = document.getElementById('img' + divname);
            if (div.style.display == "none") {
                div.style.display = "inline";
                img.src = "../kjl_images/closed.gif";
            } else {
                div.style.display = "none";
                img.src = "../kjl_images/open.gif";
            }
        }
    </script>

</asp:Content>


ASP.NET
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div>
        <asp:GridView ID="gvParentGrid" runat="server" DataKeyNames="hatchid" Width="300"
            AutoGenerateColumns="false" OnRowDataBound="gvUserInfo_RowDataBound" GridLines="None"
            BorderStyle="Solid" BorderWidth="1px" BorderColor="#df5015">
            <HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
            <RowStyle BackColor="#E1E1E1" />
            <AlternatingRowStyle BackColor="White" />
            <HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
            <Columns>
                <asp:TemplateField ItemStyle-Width="20px">
                    <ItemTemplate>
                        <a href="javascript:divexpandcollapse('div<%# Eval("hatchid") %>');">
                            <img id="imgdiv<%# Eval("hatchid") %>" width="9px" border="0" src="../kjl_images/closed.gif"  alt="" />
                        </a>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="hatchid" HeaderText="Hatch ID" HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
                <asp:BoundField DataField="hatcheryname" HeaderText="Hatchery Name" HeaderStyle-HorizontalAlign="Left">
                </asp:BoundField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <tr>
         <td colspan="100%">
     <div id="div<%# Eval("hatchid") %>" style="display: none; position: relative; left: 15px;overflow: auto">
    <asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false" BorderStyle="Double"
  BorderColor="#df5015" GridLines="None" Width="250px">
    <HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
    <RowStyle BackColor="#E1E1E1" />     <AlternatingRowStyle BackColor="White" />
    <HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
      <Columns>   <asp:BoundField DataField="hatchid" HeaderText="Region" HeaderStyle-HorizontalAlign="Left">   </asp:BoundField>
     <asp:BoundField DataField="name" HeaderText="Name" HeaderStyle-HorizontalAlign="Left">  </asp:BoundField> </Columns>                                </asp:GridView>    </div>   </td>  </tr>                   </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
    </div>
</asp:Content>


C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillHatcheryGridDetails();
            
        }

    }

    public void FillHatcheryGridDetails()
    {
        DataTable dthatcherygrid = new DataTable();
        dthatcherygrid = objhatcheryBAL.GetChickGridsdet();
        gvParentGrid.DataSource = dthatcherygrid;
        gvParentGrid.DataBind();
    }

    protected void gvUserInfo_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            GridView GridView2 = (GridView)e.Row.FindControl("gvChildGrid");
            int hatchid = Convert.ToInt16(e.Row.Cells[1].Text);
            DataTable dtRegions = new DataTable();
            objhatcheryPL.hatchid = hatchid;
            dtRegions = objhatcheryBAL.GetHatchidDetaisl(objhatcheryPL);
            GridView2.DataSource = dtRegions;
            GridView2.DataBind();
        }
    }


Inner gridview is not displaying any data. I tried and searched from google but no use the result is same iam not getting any errors.
Posted
Updated 23-Oct-20 21:46pm
v4
Comments
thatraja 21-Aug-13 15:26pm    
While debugging, are you getting data in dtRegions?
Bhagavan Raju M 21-Aug-13 15:29pm    
I am getting data when I clicked the node iths increasing the size but showing blank
thatraja 21-Aug-13 15:48pm    
what're the columns present in dtRegions?
Bhagavan Raju M 21-Aug-13 15:50pm    
@thatraja hatchid,name
thatraja 21-Aug-13 16:03pm    
OK, just remove display: none; for all rows & make sure all child grids loading?

1 solution

The problem is value of display property. inline works like span. So use block value.

To hide - display:none;
To show - display:block;

Also you could use visibility property.

FYI,
CSS display Property[^]
CSS visibility Property[^]
CSS Display and Visibility[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900