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
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 += "<tr><td>" +checkbox+ "</td><td>" + reader.GetString(1) + "</td></tr>";
}
conn.Close();
return data;
}
and here is my design code in aspx
<table class="table table-responsive table-bordered table-striped">
<tr>
<td>check</td>
<td>subject name</td>
</tr>
<%=getSubjects()%>
</table>
when i run the code it works good but the check books appear like this
System.Web.UI.WebControls.CheckBox