how to bind items in checkedlistbox from database in c#.net
  • how can i bind checkedlistbox from database like combobox we bind from valuemember and displaymember.
  • 1 Comment sorted by
  • you can try below code for fill CheckedListBox from database.

    SqlConnection objCon = new SqlConnection(@"Data Source=.\SqlExpress;Initial Catalog=dbTest;Integrated Security=True");

                SqlCommand objCmd = new SqlCommand("select ID,CountryName from tblCountry", objCon);

                SqlDataAdapter objDA = new SqlDataAdapter(objCmd);

                objDA.SelectCommand.CommandText = objCmd.CommandText.ToString();
                DataTable dt = new DataTable();

                objDA.Fill(dt);
                checkedListBox1.DataSource = dt;

                checkedListBox1.DisplayMember = "CountryName";

                checkedListBox1.ValueMember = "ID";

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

Top Posters Weekly

Optimum Creative