title: How to uncheck the checkbox within the grid view template field?
body: <p>I have two check boxes with the GridView TemplateField. I want to uncheck the checked boxes after submission. My gridview</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" HorizontalAlign="Center" DataKeyNames="ShiftID" 
  Width="177px" onrowdatabound="GridView1_RowDataBound1"&gt;
  &lt;Columns&gt;
     &lt;asp:TemplateField&gt;
       &lt;ItemTemplate&gt;
         &lt;asp:CheckBox ID="ChbGrid" runat="server" 
            oncheckedchanged="ChbGrid_CheckedChanged" /&gt;
             &lt;/ItemTemplate&gt;
             &lt;HeaderTemplate&gt;
              &lt;asp:CheckBox ID="ChbGridHead" runat="server"  AutoPostBack="True" 
            Font-Bold="True" oncheckedchanged="ChbGridHead_CheckedChanged" /&gt;
        &lt;/HeaderTemplate&gt;
     &lt;/asp:TemplateField&gt;
  &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>I tried in below mentioned methode    </p>
  
  <pre><code> public void checkboxclear()
      {
          foreach (GridViewRow row in GridView1.Rows)
          {
              CheckBox chkrow = (CheckBox)row.FindControl("ChbGrid");
              if(chkrow.Checked==true)
              {
                  chkrow.Checked = false;//it works 
              }
              else 
              {
                  CheckBox chkrow1 = (CheckBox)row.FindControl("ChbGridHead");
                  if (chkrow1.Checked == true)
                  {
                      chkrow1.Checked = false;//it shows error like "Object reference not set to instance of an object"
                  }
              }  
          }  
  </code></pre>
  
  <p>How can I improve my code to solve this issue?  Why I am unable to call these check boxes inside the  aspx.cs page  </p>