Hi ,
Try this will Guide you .
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=MOHAMED-PC\SQLEXPRESS;Initial Catalog=TestDB;Integrated Security=True");
con.Open();
foreach (ListItem item in CheckBoxList1.Items)
{
string sql =string.Format("insert into Table_1 (chk) values ('{0}')",item.Selected);
SqlCommand cmd = new SqlCommand(sql, con);
cmd.CommandType = System.Data.CommandType.Text;
cmd.ExecuteNonQuery();
}
}
<div>
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem Selected="True">3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
</asp:CheckBoxList>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</div>
Best Regards
M.Mitwalli