public partial class courses : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{ }
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{ string interests = string.Empty;
foreach (ListItem item in this.checkbox.Items)
if (item.Selected)
{
interests += item.Text;
SqlCommand cmd = new SqlCommand("Insert into tbl3(courseId) values('" + interests + "')", con); //Write Your Query to insert into database table
con.Open();
int iCount = cmd.ExecuteNonQuery();
con.Close();
}
}
}