I am trying to display the values from database. The textbox values are displayed successfully but checkbox values are not displayed, and it shows the error. i attached the error on screenshot image below
- sql = "select * from repair where repairid = '" + repairid + "'";
- SqlCommand cmd = new SqlCommand(sql, con);
- SqlDataReader dread;
- con.Open();
- dread = cmd.ExecuteReader();
- while (dread.Read())
- {
- checkBox7.CheckState = dread[6].ToString();
- }


Praveen Maurya114 reputationPosted Apr 21, 2019, 6:21 AM EDT
Kobinath Ram132 reputationPosted Apr 21, 2019, 6:55 AM EDT
Praveen Maurya114 reputationPosted Apr 21, 2019, 7:09 AM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Apr 21, 2019, 8:46 AM EDT
Rupesh KahaneRank #136 · 16.4K reputationPosted Apr 21, 2019, 8:47 PM EDT
In while loop do some modifications for property Checked , is an boolean value so make it as true / false
CheckBox.Checked= true
will work fine
Amit KumarRank #459 · 5.4K reputationPosted Apr 21, 2019, 8:12 AM EDT