Try this..here am fetch the data from db and bind it to the checkbox list..
Hope it will help you..
<div id="divCheckBoxList" runat="server" style="height: 85px; width: 182px; border: solid 1px #D7DADF;">
<asp:panel id="pnlCheckBoxList" runat="server" style="font-family: Arial; font-weight: normal; font-size: small;" xmlns:asp="#unknown">
<div id="divScroll" style="height: 85px; width: auto; overflow-y: scroll; overflow-x: hidden;">
<asp:checkboxlist id="chkLBoxKList" runat="server">
Width="100%" DataTextField=" " DataValueField=" " AutoPostBack="true">
</asp:checkboxlist>
</div>
</asp:panel>
</div>
try
{
s = WebConfigurationManager.ConnectionStrings["con"].ConnectionString;
con = new SqlConnection(s);
String str = "";
for (int i = 0; i <= chkLBoxKList.Items.Count - 1; i++)
{
if (chkLBoxKList.Items[i].Selected)
{
str = chkLBoxKList.Items[i].Text;
if (con.State == ConnectionState.Closed)
{
con.Open();
}
cmd = new SqlCommand("sp_person_chkbox_list", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@empid", SqlDbType.Int).Value = id;
cmd.Parameters.Add("@DEPARTMENT", SqlDbType.VarChar).Value = str;
cmd.ExecuteNonQuery();
}
}
}
catch (SqlException ex)
{
Console.WriteLine("SQL Error" + ex.Message.ToString());
}