Please consider the following code.
bool somevariable;
bool.TryParse(Convert.ToString(Dataset.Tables[0].Rows[0]["SomeColumnName"]), out somevariable);
CheckBox.Checked = somevariable;
In “SomeColumnName” in dataset, I have value as 1. So I assume that this will parse this 1 as TRUE in “somevariable”.
But when I try to parse this value to bool, it always returns as false.
I don’t know why.
From the
Boolean.Parsedocumentation:1and0are not equivalent to the strings"true"or"false".Assuming your
SomeColumnNameis indeed a boolean field, you can do:Or directly convert to boolean (thanks @Bolu):