• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1497
  • Last Modified:

"string was not recognized as a valid boolean" datagrid checkbox

Hello,

I have a checkbox in my databound datagrid.  however, when attempting to change the checkmark, I get the following error:

string was not recognized as a valid boolean.

anyone here know how to resolve this issue?

thanks in advance.
0
brdrok
Asked:
brdrok
  • 2
  • 2
2 Solutions
 
gillgatesCommented:
are you saying...


if object.Check = "true"
{}  

if so, say

if object.Check = true
{}


Same with false, "true" is a string, true is boolean.

if that is not the issue post some code.
0
 
aacoolCommented:
Actually, that code should be

if(object.Check == true)
{
//...
}
0
 
gillgatesCommented:
Thats right, but my point is "true" is a string... I was just doing some vb6 earlier today and confused myself.
0
 
brdrokAuthor Commented:
Hello

thanks for the answers.  the answer pointed me in the right direction....

my original code was

//creating column
System.Windows.Forms.DataGridBoolColumn dbc = new DataGridBoolColumn();
dbc.TrueValue = "Yes";  //-----> changed it to dbc.TrueValue = true;
dbc.FalseValue = "No";  //-----> changed it to dbc.FalseValue = false'
tableStyle.GridColumnStyles.Add(dbc);
tableStyle.GridColumnStyles[1].HeaderText = "Scaled?";
tableStyle.GridColumnStyles[1].MappingName = myDataSet.Tables[0].Columns["Scaled"].ColumnName;


0
 
brdrokAuthor Commented:
i split the points 100:25....hope you guys think it's fair.

thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now