title: Show/hide button onselecting/deseleting of checkbox
body: <p>I am using gridview and there is a checkbox (with name Select all) in header to select all checkboxes in item template. when I click on this check box it select all the checkboxes in item template and display the delete button and on removing check it hide the delete button. Now, what I want is, when I click the select all checkbox and then if I remove all checkboxes from the item templates one by one the select all checkbox check to be removed and delete button go hide. if I select one or more checkbox from item template the delete button become visible, and if I deselect any checkbox the delete button should be visible until and unless all checkboxes are not cleared.</p>
  
  <p>I try this code but not work properly. Can anybody help me please?</p>
  
  <p>This code is on Select All check boxes.</p>
  
  <pre><code>  protected void chkSelectAll_CheckedChanged(object sender, EventArgs e)  
    {
      Button btnDel = (Button)ViewsStudGV.FooterRow.FindControl("btnDel");
      CheckBox allchk = (CheckBox)ViewsStudGV.HeaderRow.FindControl("chkSelectAll");
  
      CheckBox chk;
  
      foreach (GridViewRow rowItem in ViewsStudGV.Rows)
      {
          chk = (CheckBox)(rowItem.Cells[0].FindControl("chkSelect"));
          chk.Checked = ((CheckBox)sender).Checked;
          if (chk.Checked == true)
          {
              btnDel.Visible = true;                
              allchk.Text = "Select None";
          }
          else
          {
              btnDel.Visible = false;
              allchk.Text = "Select All";
          }
      }
  
  }
  </code></pre>
  
  <p>and this code is on item template checkbox</p>
  
  <pre><code>protected void chkSelect_CheckedChanged(object sender, EventArgs e)
  {
      CheckBox chk = (CheckBox)ViewsStudGV.FindControl("chkSelect");
      Button btnDel = (Button)ViewsStudGV.FooterRow.FindControl("btnDel");
      CheckBox allchk = (CheckBox)ViewsStudGV.HeaderRow.FindControl("chkSelectAll");
  
      CheckBox c = (CheckBox)sender as CheckBox;
      if (c.Checked == true &amp;&amp; allchk.Checked==true)
      {
          btnDel.Visible = true;
      }
      else if(c.Checked == false &amp;&amp; allchk.Checked==true)
      {
          btnDel.Visible = false;
      }
      else if (c.Checked == true &amp;&amp; allchk.Checked == false)
      {
          btnDel.Visible = true;
      }
      else if (c.Checked == false &amp;&amp; allchk.Checked == false)
      {
          btnDel.Visible = false;
      }
  }
  </code></pre>