Reputation: 11
This is the line where the String gets assigned to a boolean property:
chkreputative.Checked = gvmanufacturers.DataKeys[rowindex]["IsReputative"].ToString();
Upvotes: 1
Views: 1214
Reputation: 7573
Get rid of the ToString()
call, and apply the correct cast. You are trying to assign a String
value to a Boolean
value, that's why you get the exception.
Depending on what type the DataKeys
object is, you can try some of the following:
chkreputative.Checked = (bool)gvmanufacturers.DataKeys[rowindex]["IsReputative"];
chkreputative.Checked = Boolean.Parse(gvmanufacturers.DataKeys[rowindex]["IsReputative"]);
chkreputative.Checked = Convert.ToBoolean(gvmanufacturers.DataKeys[rowindex]["IsReputative"]);
Upvotes: 2