title: Find GridView control inside the div using jQuery
body: <p>GridView:</p>
  
  <pre><code>&lt;asp:GridView ID="gvParentGrid" runat="server" DataKeyNames="dc_code" Width="100%"
      OnRowCommand="gvParentGrid_RowCommand" AutoGenerateColumns="false"
      OnRowDataBound="gvParentGrid_RowDataBound" OnRowCreated="gvParentGrid_RowCreated"
      GridLines="None" BorderStyle="Solid" BorderWidth="1px" BorderColor="#df5015"&gt;
  &lt;HeaderStyle BackColor="#0080ff" Font-Bold="true" ForeColor="White" /&gt;
  &lt;RowStyle BackColor="#E1E1E1" /&gt;
  &lt;AlternatingRowStyle BackColor="White" /&gt;
  &lt;Columns&gt;
  &lt;asp:TemplateField ItemStyle-Width="20px"&gt;
    &lt;ItemTemplate&gt;
      &lt;a href="JavaScript:divexpandcollapse('div&lt;%# Eval(" dc_code ") %&gt;');"&gt;
      &lt;img id='imgdiv&lt;%# Eval("dc_code") %&gt;' width="9px" border="0" src="../Images/plus.gif" alt="" /&gt;&lt;/a&gt;
    &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  &lt;asp:TemplateField HeaderText="SNo"&gt;
    &lt;ItemTemplate&gt;
      &lt;%#Container.DataItemIndex+1 %&gt;
    &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  &lt;asp:BoundField DataField="dc_code" HeaderText="dc_code" HeaderStyle-HorizontalAlign="Left" /&gt;
  &lt;asp:BoundField DataField="zone" HeaderText="Zone" HeaderStyle-HorizontalAlign="Left" /&gt;
  &lt;asp:TemplateField ItemStyle-Width="20px" HeaderText="Value"&gt;
    &lt;ItemTemplate&gt;
      &lt;%--&lt;a href="JavaScript:SetLeadDay('div&lt;%# Eval(" dc_code ") %&gt;');"&gt;&lt;/a&gt;--%&gt;
        &lt;asp:TextBox ID="txtgvZValue" runat="server" Width="60px" Text='&lt;%# Bind("value") %&gt;' onkeypress="return onlyNumbers(this);" MaxLength="3"&gt;&lt;/asp:TextBox&gt;
    &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  &lt;asp:TemplateField HeaderText="Action" ItemStyle-Width="75px" ControlStyle-Width="75px" ItemStyle-HorizontalAlign="Center"&gt;
    &lt;ItemTemplate&gt;
      &lt;asp:Button ID="btngvZApply" runat="server" Text="Apply" Width="75px" CommandArgument='&lt;%# Eval("dc_code") %&gt;' CommandName="Apply" /&gt;
    &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  &lt;asp:TemplateField&gt;
    &lt;ItemTemplate&gt;
      &lt;tr&gt;
        &lt;td colspan="98%"&gt;
          &lt;div id='div&lt;%# Eval("dc_code") %&gt;' style="display: none; position: relative; left: 15px; overflow: auto"&gt;
            &lt;asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false" BorderStyle="Double"
                BorderColor="#df5015" OnRowCommand="gvChildGrid_RowCommand" OnRowCreated="gvChildGrid_RowCreated" GridLines="None"
                Width="98%" OnRowDataBound="gvChildGrid_RowDataBound"&gt;
              &lt;HeaderStyle BackColor="#0080ff" Font-Bold="true" ForeColor="White" /&gt;
              &lt;RowStyle BackColor="#E1E1E1" /&gt;
              &lt;AlternatingRowStyle BackColor="White" /&gt;
              &lt;Columns&gt;
                &lt;asp:TemplateField ItemStyle-Width="20px"&gt;
                  &lt;ItemTemplate&gt;
                    &lt;a href="JavaScript:divexpandcollapse('divG&lt;%# Eval(" family ") %&gt;');"&gt;
                    &lt;img id='imgdivG&lt;%# Eval("family") %&gt;' width="9px" border="0" src="../Images/plus.gif" alt="" /&gt;&lt;/a&gt;
                  &lt;/ItemTemplate&gt;
                &lt;/asp:TemplateField&gt;
                &lt;asp:TemplateField HeaderText="SNo"&gt;
                  &lt;ItemTemplate&gt;
                    &lt;%#Container.DataItemIndex+1 %&gt;
                  &lt;/ItemTemplate&gt;
                &lt;/asp:TemplateField&gt;
                &lt;asp:BoundField DataField="family" HeaderText="family" HeaderStyle-HorizontalAlign="Left" /&gt;
                &lt;asp:BoundField DataField="familyValue" HeaderText="familyValue" HeaderStyle-HorizontalAlign="Left" /&gt;
                &lt;asp:TemplateField ItemStyle-Width="20px" HeaderText="Value"&gt;
                  &lt;ItemTemplate&gt;
                    &lt;asp:TextBox ID="txtgvGValue" runat="server" Width="60px" Text='&lt;%# Bind("value") %&gt;' onkeypress="return onlyNumbers(this);" MaxLength="3"&gt;&lt;/asp:TextBox&gt;
                  &lt;/ItemTemplate&gt;
                &lt;/asp:TemplateField&gt;
                &lt;asp:TemplateField HeaderText="Action"&gt;
                  &lt;ItemTemplate&gt;
                    &lt;asp:Button ID="btngvGApply" runat="server" Text="Apply" Width="75px" /&gt;
                  &lt;/ItemTemplate&gt;
                &lt;/asp:TemplateField&gt;
                &lt;asp:TemplateField&gt;
                  &lt;ItemTemplate&gt;
                    &lt;tr&gt;
                      &lt;td colspan="98%"&gt;
                        &lt;div id='divG&lt;%# Eval("family") %&gt;' style="display: none; position: relative; left: 15px; overflow: auto"&gt;
                          &lt;asp:GridView ID="gvSupplier" runat="server" AutoGenerateColumns="false" BorderStyle="Double"
                              BorderColor="#df5015" OnRowCreated="gvSupplier_RowCreated" GridLines="None" Width="98%"&gt;
                            &lt;HeaderStyle BackColor="#0080ff" Font-Bold="true" ForeColor="White" /&gt;
                            &lt;RowStyle BackColor="#E1E1E1" /&gt;
                            &lt;AlternatingRowStyle BackColor="White" /&gt;
                            &lt;Columns&gt;
                              &lt;asp:TemplateField HeaderText="SNo"&gt;
                                &lt;ItemTemplate&gt;
                                &lt;/ItemTemplate&gt;
                              &lt;/asp:TemplateField&gt;
                              &lt;asp:BoundField DataField="supplierCode" HeaderText="supplierCode" HeaderStyle-HorizontalAlign="Left" /&gt;
                              &lt;asp:BoundField DataField="supplierName" HeaderText="supplierName" HeaderStyle-HorizontalAlign="Left" /&gt;
                              &lt;asp:TemplateField ItemStyle-Width="20px" HeaderText="Value"&gt;
                                &lt;ItemTemplate&gt;
                                  &lt;asp:TextBox ID="gvSValue" runat="server" Width="60px" Text='&lt;%# Bind("value") %&gt;' onkeypress="return onlyNumbers(this);" MaxLength="3"&gt;&lt;/asp:TextBox&gt;
                                &lt;/ItemTemplate&gt;
                              &lt;/asp:TemplateField&gt;
                            &lt;/Columns&gt;
                          &lt;/asp:GridView&gt;
                        &lt;/div&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
                  &lt;/ItemTemplate&gt;
                &lt;/asp:TemplateField&gt;
              &lt;/Columns&gt;
            &lt;/asp:GridView&gt;
          &lt;/div&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre class="lang-js prettyprint-override"><code>function divexpandcollapse(divname) {
      alert(divname);
      var div = document.getElementById(divname);
      var img = document.getElementById('img' + divname);
  
      if (div.style.display == "none") {
          div.style.display = "inline";
          img.src = "../Images/minus.gif";
      } else {
          div.style.display = "none";
          img.src = "../Images/plus.gif";
      }
  }
  </code></pre>
  
  <p>In that JavaScript function, I am passing the div ID. By using the div ID, I want to find the GridView which is placed inside the corresponding div tag.</p>
  
  <p>Here, I am going to find the grid and then assign the value to one of its column by looping.</p>
  
  <p>How to find the grid placed after the div?</p>