Forums - C# Corner

Forum guidelines
Kinjal Sonachhatra

Kinjal Sonachhatra

  • 1.6k
  • 96
  • 974

Retrieve Data from SQL to Checkboxlist winform

Dec 25 2018 11:58 PM
DAL:
 
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;
adp.Fill(dt);
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
}
con.Close();
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)