title: delete selected checkbox in repeater
body: <p>I have a repeater with checkbox in it and I want to delete subcategories the items/records from table which are selected with checkbox in to it. any ideas?</p>
  
  <p><strong>TABLE STRUCTURE:</strong><br>
  software
  <code>CategoryID=100, SubCategoryID=NULL (main category)
  ASP.NET
  CategoryID=100, SubCategoryID=100 (sub category)</code></p>
  
  <p><strong>I got error:</strong><br></p>
  
  <blockquote>
    <p>Incorrect syntax near '='.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '='.</p>
  </blockquote>
  
  <pre><code>// select all
   protected void btnSelectAll_Click(object sender, EventArgs e)
      {
          foreach (RepeaterItem ri in rpCategory.Items)
          {
   CheckBox checkBoxApproved = ri.FindControl("checkBoxApproved") as CheckBox;
              if (checkBoxApproved != null)
              {
                  if (checkBoxApproved.Checked == true)
                  {
                      checkBoxApproved.Checked = false;
                  }
                  else
                  {
                      checkBoxApproved.Checked = true;
                  }
              }
          }
      }
  
      // delete all
       protected void btnDelete_Click(object sender, EventArgs e)
          {
              for (int i = 0; i &lt; rpCategory.Items.Count; i++)
              {
                  CheckBox CheckBox1 = (CheckBox)
                  rpCategory.Items[i].FindControl("checkBoxApproved");
  
                  if (((CheckBox)rpCategory.Items[i].FindControl("checkBoxApproved")).Checked)
                  {
                      CheckBox CheckBox = (CheckBox)rpCategory.Items[i].FindControl("checkBoxApproved");
  
                      SqlConnection cnn = system.baglan();
                       SqlCommand cmd = new SqlCommand("DELETE FROM TBLCATEGORIES where  SubCategoryID="+CategoryID, cnn);
                      cmd.ExecuteNonQuery();
                      Response.Redirect("SubCategories.aspx?Message=Success!");
                 }
            }
  </code></pre>