title: Nested gridview closes when trying to edit or click on a checkbox
body: <p>My script:</p>
  
  <pre><code>function pageLoad(sender, args) {
      $("[src*=plus]").live("click", function () {
          $(this).closest("tr").after("&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td colspan = '999'&gt;" + $(this).next().html() + "&lt;/td&gt;&lt;/tr&gt;")
          $(this).attr("src", "../img/minus.png");
          $(this).next().next().val(1);
      });
  
      $("[src*=minus]").live("click", function () {
          $(this).attr("src", "../img/plus.png");
          $(this).closest("tr").next().remove();
          $(this).next().next().val("");
      });
  
      $(function () {
          $("[id*=IsExpanded]").each(function () {
              if ($(this).val() == "1") {
                  $(this).closest("tr").after("&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td colspan = '999'&gt;" + $("[id*=childpanel]", $(this).closest("tr")).html() + "&lt;/td&gt;&lt;/tr&gt;")
                  $("[src*=plus]", $(this).closest("tr")).attr("src", "../img/minus.png");
              }
          });
      });
  }
  
  function Check_Click(objRef) {
      //Get the Row based on checkbox
      var row = objRef.parentNode.parentNode;
  
      //Get the reference of GridView
      var GridView = row.parentNode;
  
      //Get all input elements in Gridview
      var inputList = GridView.getElementsByTagName("input");
  
      for (var i = 0; i &lt; inputList.length; i++) {
          //The First element is the Header Checkbox
          var headerCheckBox = inputList[0];
  
          //Based on all or none checkboxes
          //are checked check/uncheck Header Checkbox
          var checked = true;
  
          if (inputList[i].type == "checkbox" &amp;&amp; inputList[i] != headerCheckBox) {
              if (!inputList[i].checked) {
                  checked = false;
                  break;
              }
          }
      }
  
      headerCheckBox.checked = checked;        
  }
  
  function checkAll(objRef) {
      var GridView = objRef.parentNode.parentNode.parentNode;
      var inputList = GridView.getElementsByTagName("input");
  
      for (var i = 0; i &lt; inputList.length; i++) {
          //Get the Cell To find out ColumnIndex
          var row = inputList[i].parentNode.parentNode;
  
          if (inputList[i].type == "checkbox" &amp;&amp; objRef != inputList[i]) {
              if (objRef.checked) {
                  inputList[i].checked = true;
              }
              else {
                  inputList[i].checked = false;
              }
          }
      }       
  }
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>&lt;body style="background-color: White"&gt;
      &lt;form id="form1" runat="server"&gt;
          &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;&lt;/asp:ScriptManager&gt;
          &lt;div&gt;
              &lt;ul class="topnav"&gt;
                  &lt;li&gt;
                      &lt;img src="https://cync.cinergycinemas.com/Images/Logo-15.png" alt="Logo" /&gt;
                  &lt;/li&gt;
                  &lt;li&gt;&lt;a href="Adminhome.aspx"&gt;Home&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;
                      &lt;a class="active" href="timecontrol.aspx"&gt;Employees&lt;br /&gt;
                          &lt;asp:Label ID="lbltotalemp" runat="server" Font-Bold="True"&gt;&lt;/asp:Label&gt;
                      &lt;/a&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;a href="clockedIN.aspx"&gt;Clocked IN&lt;br /&gt;
                          &lt;asp:Label ID="lblin" runat="server" Font-Bold="True"&gt;&lt;/asp:Label&gt;
                      &lt;/a&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;a href="Overtimegv.aspx"&gt;Overtime&lt;br /&gt;
                          &lt;asp:Label ID="lblot" runat="server" Font-Bold="True"&gt;&lt;/asp:Label&gt;
                      &lt;/a&gt;
                  &lt;/li&gt;
                  &lt;li class="right"&gt;&lt;a href="EID2.aspx"&gt;Sign out&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
  
          &lt;%-- Search box autocomplete extender using ajax --%&gt;
          &lt;br /&gt;
          &lt;br /&gt;
          &lt;br /&gt;
          &lt;div style="margin: 50px; text-align: center"&gt;
              &lt;asp:TextBox ID="txtSearch" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
                  ServiceMethod="SearchCustomers"
                  MinimumPrefixLength="1"
                  CompletionInterval="100" EnableCaching="false" CompletionSetCount="0"
                  TargetControlID="txtSearch"
                  FirstRowSelected="True"
                  CompletionListCssClass="AutoExtender"
                  CompletionListItemCssClass="AutoExtenderList"
                  CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                  CompletionListElementID="divwidth"&gt;
              &lt;/ajaxToolkit:AutoCompleteExtender&gt;
  
              &lt;asp:Button ID="btnSearch" runat="server" Text="Search" /&gt;&lt;br /&gt;
              &lt;br /&gt;
              &lt;%--   &lt;input type="checkbox" id="Virtual_Keyboard" /&gt;Use Virtual Keyboard&lt;br /&gt;--%&gt;
  
              &lt;%--  Gridview 1--%&gt;
  
              &lt;asp:GridView ID="MainGV" runat="server" AutoGenerateColumns="False" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" DataKeyNames="EID" HorizontalAlign="Center" EmptyDataText="No Data Found. Try Again !" AllowPaging="True" Font-Bold="True" ForeColor="Black" AllowSorting="True" OnRowDataBound="MainGV_RowDataBound"&gt;
                  &lt;AlternatingRowStyle CssClass="alt"&gt;&lt;/AlternatingRowStyle&gt;
                      &lt;Columns&gt;
                          &lt;asp:TemplateField&gt;&lt;%--Plus and minus buttons--%&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;img src="images/plus.png" style="cursor: pointer" /&gt;
                                  &lt;asp:Panel ID="Panel1" runat="server" Style="display: none"&gt;
                                      &lt;%--Style="display: none"--%&gt;
                                      &lt;asp:GridView ID="childGV" runat="server" AutoGenerateColumns="False" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" DataKeyNames="EID" HorizontalAlign="Center" EmptyDataText="No Data / Approved !" AllowPaging="True" Font-Bold="True" ForeColor="Black"&gt;
                                          &lt;AlternatingRowStyle CssClass="alt" /&gt;
                                          &lt;Columns&gt;
                                              &lt;asp:TemplateField&gt;
                                                  &lt;HeaderTemplate&gt;
                                                      &lt;asp:CheckBox runat="server" ID="chkCheckall" onclick="checkAll(this)" AutoPostBack="True"&gt;&lt;/asp:CheckBox&gt;
                                                  &lt;/HeaderTemplate&gt;
                                                  &lt;ItemTemplate&gt;
                                                      &lt;asp:CheckBox runat="server" ID="chkCheck" onclick="Check_Click(this)" AutoPostBack="True" OnCheckedChanged="chkCheck_CheckedChanged"&gt;&lt;/asp:CheckBox&gt;
                                                  &lt;/ItemTemplate&gt;
                                              &lt;/asp:TemplateField&gt;
                                              &lt;asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" InsertVisible="False" SortExpression="ID" Visible="false"&gt;&lt;/asp:BoundField&gt;
                                              &lt;asp:BoundField DataField="EID" HeaderText="EID" ReadOnly="True" SortExpression="EID" Visible="false"&gt;&lt;/asp:BoundField&gt;
                                              &lt;asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" Visible="false"&gt;&lt;/asp:BoundField&gt;
                                              &lt;asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" Visible="false"&gt;&lt;/asp:BoundField&gt;
                                              &lt;asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" Visible="false"&gt;&lt;/asp:BoundField&gt;
                                              &lt;asp:BoundField DataField="Department" HeaderText="Department" SortExpression="Department" Visible="false"&gt;&lt;/asp:BoundField&gt;
                                              &lt;asp:BoundField DataField="JobFunctionalTitle" HeaderText="JobFunctionalTitle" SortExpression="JobFunctionalTitle" Visible="false"&gt;&lt;/asp:BoundField&gt;
                                              &lt;asp:BoundField DataField="IN_Time" HeaderText="IN_Time" ReadOnly="True" SortExpression="IN_Time"&gt;&lt;/asp:BoundField&gt;
                                              &lt;asp:BoundField DataField="OUT_Time" HeaderText="OUT_Time" ReadOnly="True" SortExpression="OUT_Time"&gt;&lt;/asp:BoundField&gt;
                                              &lt;asp:BoundField DataField="Department1" HeaderText="Department1" SortExpression="Department1"&gt;&lt;/asp:BoundField&gt;
                                              &lt;asp:BoundField DataField="Hours2" HeaderText="Hours2" SortExpression="Hours2"&gt;&lt;/asp:BoundField&gt;
                                              &lt;asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes"&gt;&lt;/asp:BoundField&gt;
                                          &lt;/Columns&gt;
                                          &lt;PagerStyle CssClass="pgr" /&gt;
                                      &lt;/asp:GridView&gt;
                                  &lt;/asp:Panel&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField HeaderText="EID" SortExpression="EID"&gt;
                              &lt;%--&lt;EditItemTemplate&gt;
                                  &lt;asp:Label runat="server" Text='&lt;%# Eval("EID") %&gt;' ID="Label1"&gt;&lt;/asp:Label&gt;
                              &lt;/EditItemTemplate&gt;--%&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:Label runat="server" Text='&lt;%# Bind("EID") %&gt;' ID="Label1"&gt;&lt;/asp:Label&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField HeaderText="FullName" SortExpression="FullName"&gt;
                              &lt;EditItemTemplate&gt;
                                  &lt;asp:Label runat="server" Text='&lt;%# Eval("FullName") %&gt;' ID="Label2"&gt;&lt;/asp:Label&gt;
                              &lt;/EditItemTemplate&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:Label runat="server" Text='&lt;%# Bind("FullName") %&gt;' ID="Label2"&gt;&lt;/asp:Label&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField HeaderText="Gender" SortExpression="Gender"&gt;
                              &lt;EditItemTemplate&gt;
                                  &lt;asp:TextBox runat="server" Text='&lt;%# Bind("Gender") %&gt;' ID="TextBox1"&gt;&lt;/asp:TextBox&gt;
                              &lt;/EditItemTemplate&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:Label runat="server" Text='&lt;%# Bind("Gender") %&gt;' ID="Label3"&gt;&lt;/asp:Label&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField HeaderText="Department" SortExpression="Department"&gt;
                              &lt;EditItemTemplate&gt;
                                  &lt;asp:TextBox runat="server" Text='&lt;%# Bind("Department") %&gt;' ID="TextBox2"&gt;&lt;/asp:TextBox&gt;
                              &lt;/EditItemTemplate&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:Label runat="server" Text='&lt;%# Bind("Department") %&gt;' ID="Label4"&gt;&lt;/asp:Label&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField HeaderText="JobFunctionalTitle" SortExpression="JobFunctionalTitle"&gt;
                              &lt;EditItemTemplate&gt;
                                  &lt;asp:TextBox runat="server" Text='&lt;%# Bind("JobFunctionalTitle") %&gt;' ID="TextBox3"&gt;&lt;/asp:TextBox&gt;
                              &lt;/EditItemTemplate&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:Label runat="server" Text='&lt;%# Bind("JobFunctionalTitle") %&gt;' ID="Label5"&gt;&lt;/asp:Label&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField HeaderText="Location" SortExpression="Location"&gt;
                              &lt;EditItemTemplate&gt;
                                  &lt;asp:TextBox runat="server" Text='&lt;%# Bind("Location") %&gt;' ID="TextBox4"&gt;&lt;/asp:TextBox&gt;
                              &lt;/EditItemTemplate&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:Label runat="server" Text='&lt;%# Bind("Location") %&gt;' ID="Label6"&gt;&lt;/asp:Label&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField HeaderText="Location_Name" SortExpression="Location_Name" Visible="false"&gt;
                              &lt;EditItemTemplate&gt;
                                  &lt;asp:TextBox runat="server" Text='&lt;%# Bind("Location_Name") %&gt;' ID="TextBox5"&gt;&lt;/asp:TextBox&gt;
                              &lt;/EditItemTemplate&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:Label runat="server" Text='&lt;%# Bind("Location_Name") %&gt;' ID="Label7"&gt;&lt;/asp:Label&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;        
                      &lt;/Columns&gt;
                      &lt;PagerStyle CssClass="pgr"&gt;&lt;/PagerStyle&gt;
                  &lt;/asp:GridView&gt;
              &lt;/div&gt;
              &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:dev_prashanthConnectionString %&gt;" SelectCommand="Sp_timedeptdisplaytest1" SelectCommandType="StoredProcedure"&gt;
                  &lt;SelectParameters&gt;
                      &lt;asp:ControlParameter ControlID="HFLocnum" Name="Locnum" PropertyName="Value" Type="String" DefaultValue=""&gt;&lt;/asp:ControlParameter&gt;
                      &lt;asp:ControlParameter ControlID="txtSearch" PropertyName="Text" DefaultValue="NULL" Name="SearchText" Type="String"&gt;&lt;/asp:ControlParameter&gt;
                  &lt;/SelectParameters&gt;
              &lt;/asp:SqlDataSource&gt;
  
              &lt;%--&lt;asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString='&lt;%$ ConnectionStrings:DWHConnectionString %&gt;' SelectCommand="SELECT * FROM [tbl_EID_PIN]"&gt;&lt;/asp:SqlDataSource&gt;--%&gt;
              &lt;asp:HiddenField ID="HFclkincount" runat="server" /&gt;
              &lt;asp:HiddenField ID="HFtotalcount" runat="server" /&gt;
              &lt;asp:HiddenField ID="HFLocnum" runat="server" /&gt;
              &lt;asp:HiddenField ID="HFhours2" runat="server" /&gt;
              &lt;script&gt;
                  function CreatePopup() {
                      return confirm("Do you confirm?");
                  }
              &lt;/script&gt;
              &lt;asp:HiddenField ID="HFEID" runat="server" /&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p>I need to have mu child gridview open when i select the checkbox. 
  Please provide me some guidance.</p>