How do I populate my CheckBoxList with values from my database?

Taig

New Member
How do I set the \[code\]CheckBoxList\[/code\] values with my values stored in my database? I have tried using a \[code\]datareader\[/code\] but it doesn't work and I don't know why.My Code:\[code\]cmd = new SqlCommand("SELECT [SeatID], [Flag] FROM [SeatingPlan] WHERE ([SectionID] = 1 )", con);dr = cmd.ExecuteReader();while (dr.Read()){ for (int i = 0; i < 15; i++) { if (dr.GetString(1).Equals("true")) { chkBoxDaysList.Items.Selected = true; chkBoxDaysList.Items.Enabled = false; } }}\[/code\]
 
Back
Top