Forums - C# Corner

Forum guidelines
Kinjal Sonachhatra

Kinjal Sonachhatra

  • 1.7k
  • 101
  • 1.2k

Retrieve Data from SQL to Checkboxlist winform

Dec 25 2018 11:58 PM
string str = "select * from Employee where Id=" + e.eID + "";
SqlCommand cmd = new SqlCommand(str, con);
DataTable dt = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter();
adp.SelectCommand = cmd;
string[] s = new string[] { };
if (dt.Rows.Count >= 0)
//e.eHobbies = dt.Rows[0]["Hobbies"].ToString(); //checkboxlist
e.eGender = dt.Rows[0]["Gender"].ToString(); //radiobutton
e.eName = dt.Rows[0]["Name"].ToString(); //Textbox
e.eMobile = dt.Rows[0]["Mobile"].ToString(); //Textbox
e.eCity = dt.Rows[0]["City"].ToString(); dropdownlist
e.eEmail = dt.Rows[0]["Email"].ToString(); //Textbox
return dt;
Here I have Issue about query that which query can I use for getting values from SQL to checkbox list. I want to checked the items which is already stored in database but i have confusion about query as well as code that how to get all things properly. Hobbies are belongs to CheckboxList. As well as I want to select radiobutton from database.
Thanks in Advance 

Answers (9)