string interests = string.Empty;
foreach (ListItem item in this.CheckBoxList1.Items)
if (item.Selected)
interests += item + ",";
SqlCommand cmd = new SqlCommand("Insert into Demo values('" + interests + "')", cn); //Write Your Query to insert into database table
cn.Open();
int iCount = cmd.ExecuteNonQuery();
cn.Close();
void LoadCheckList()
{
string intersts = "";
SqlCommand cmd = new SqlCommand("Select Interests from Demo", cn); // Write your Query i have taken as sample
SqlDataReader dr;
cn.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
intersts = dr["Interests"].ToString();
}
cn.Close();
string[] arr = intersts.Split(',');
foreach (ListItem item in this.CheckBoxList1.Items)
{
foreach (string s in arr)
{
if (item.Text== s)
{
item.Selected = true;
}
}
}
}