title: checkbox.Visible = false; but is it stil there?
body: <p>I Have a Datalist in C# whith alot of checkboxes and firstnames. When a button is clicked, first, all data in the table is getting deleted and for every checkbox that is checked, the ID is inserted in the tabel again. That works well. </p>
  
  <p>The problem is when I just display certain checkboxes for example where firstname is John. All checkboxes whith an ID is displayed but only those that contains John are Visible. If I check a few more of the checkboxes and click the button, again all all rows are getting deleted and then my thought was that the checkboxes that is visible = false; Stil are there and are getting inserted again. But they are not... </p>
  
  <p>Are there another way to do it so it works like I want? </p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
  {
      GetEmployee();
      CompareEmployee();
  }
  
  private void GetEmployee()
  {
  
  string FirstName = table.Rows[i]["FirstName"].ToString();
  string qs = (Request.QueryString["search"].ToString());
  
  
   DataTable table = SearchPerson(search);
   for (int i = 0; i &lt; table.Rows.Count; i++)
      {
  
          CheckBox checkbox = new CheckBox();
          checkbox.ID = table.Rows[i]["UserID"].ToString();
          checkbox.Visible = false;
  
          HyperLink hlFirstName = new HyperLink();
          hlFirstName.Text = table.Rows[i]["FirstName"].ToString();            
          hlFirstName.Visible = false;
  
  
          string FirstName = table.Rows[i]["FirstName"].ToString();            
          string qs = (Request.QueryString["search"].ToString());
  
          if (qs.Contains(FirstName))
          {
              checkbox.Visible = true;
              hlFirstName.Visible = true;                
          }
  
          phEmployee.Controls.Add(checkbox);
          phEmployee.Controls.Add(hlFirstName);
  
      }
  }
  
  private void CompareEmployee()
  {
      int UserID = ((User)Session["LoggedInUser"]).UserID;
      DataTable table = new DataTable();
      table = GetEmployee(UserID);
  
      foreach (Control c in phEmployee.Controls)
      {
          if (c.GetType() == typeof(CheckBox))
          {
              for (int i = 0; i &lt; table.Rows.Count; i++)
              {
                  if (c.ID == table.Rows[i][0].ToString())
                  {
                      (c as CheckBox).Checked = true;
                  }
              }
          }
      }
  }
  
  protected void btnUpdate_Click(object sender, EventArgs e)
  {
      int UserID = ((User)Session["LoggedInUser"]).UserID;
      {            
          DeleteEmployee(UserID);
  
          foreach (Control c in phEmployee.Controls)
          {
              if (c.GetType() == typeof(CheckBox))
              {
                  if ((c as CheckBox).Checked)
                  {
                      AddEmployee(c.ID, UserID);
                  }
              }
          }
          Response.Redirect("Default.aspx");
      }
  }
  </code></pre>