title: how to create checkbox dynamically inside cell of table using asp.net and c#
body: <p>I am using asp.net with c# and  I am trying to create checkbox dynamically from code and add it to my page 
  here is my c# code in file aspx.cs </p>
  
  <pre><code>public String getSubjects()
  {
      SqlConnection conn = new DB_Connection().getConnection();
      SqlCommand cmd = new SqlCommand("select * from subjects", conn);
  
      conn.Open();
      SqlDataReader reader = cmd.ExecuteReader();
      String data = "";
      while (reader.Read())
      {
          CheckBox checkbox = new CheckBox();
          checkbox.ID =Convert.ToString(reader.GetInt32(0));           
  
          data += "&lt;tr&gt;&lt;td&gt;" +checkbox+ "&lt;/td&gt;&lt;td&gt;" + reader.GetString(1) + "&lt;/td&gt;&lt;/tr&gt;";
  
      }
      conn.Close();
      return data;
  }
  </code></pre>
  
  <p>and here is my design code in aspx</p>
  
  <pre><code>&lt;table class="table table-responsive table-bordered table-striped"&gt;
      &lt;tr&gt;
          &lt;td&gt;check&lt;/td&gt;
          &lt;td&gt;subject name&lt;/td&gt;
  
      &lt;/tr&gt;
      &lt;%=getSubjects()%&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>when i run the code it works good but the check books appear like this </p>
  
  <blockquote>
    <p>System.Web.UI.WebControls.CheckBox</p>
  </blockquote>