How to bind data from database into checkboxlist at runtime?
By James J
Runtime it will bind data from the database into the checkboxlist...
private void CheckboxListBind()
{
SqlConnection conn = new SqlConnection("connection string");
conn.Open();
SqlDataReader dr;
SqlCommand cmd = new SqlCommand("SELECT ename FROM employee", conn);
dr
= cmd.ExecuteReader();
while (dr.Read())
{
checkedListBox1.Items.Add(dr.GetValue(0).ToString());
}
conn.Close();
}
How to bind data from database into checkboxlist at runtime? (1571 Views)