Gabriel olayinka

Gabriel olayinka

  • NA
  • 119
  • 4.2k

Working with ListCheckBox

Mar 5 2018 1:38 AM
i have a database table that consist of ID(int) , NAME(varchar) , ADDRESSING, STATUS(int) ..... I want to Populate a listCheckBox with the table data and check every row where the STATUS ==1..... I'm really getting stuck. I need help on how to do this
 
here is my code.... i'm working with c# winform
void fillChecklist()
{
try
{
con.Open();
string ct = "select * FROM Detail";
cmd = new SqlCommand(ct);
cmd.Connection = con;
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
//fill the checkListBox with all the table record
{
checkedListBox1.Items.Add(rdr.GetString(1));
if (rdr.GetString(1)==1)
{
//check every row in the checkListbox where STATUS =1
//this is where I’m having major issue
}//end if
}//end while
}//end try
finally
{
con.Close();
}
}//end fillChecklist method
 

Answers (4)