I have a boolean field in a MySQL database. When displaying the selected rows from the DB on the datagrid in C#, I want this field to be displayed as "true" or "false".
Can somebody help me out in telling how can I do it?
I have a boolean field in a MySQL database. When displaying the selected rows from the DB on the datagrid in C#, I want this field to be displayed as "true" or "false".
Can somebody help me out in telling how can I do it?
Typically, this will happen automatically. It depends on how you're pulling the Boolean across into C#, but it will normally get treated as a bool, which in turn will turn into "True" or "False" when it's ToString() method is called.
String.Format("The boolean value is {0}", boolValue ? "true" : "false");
You could wrap the ternary statement in some ToFriendlyString() extension method. This will allow you to say ANYTHING; true/false, yes/no, up/down, black/white, whatever the Boolean value really represents in your model.
Boolean.ToString() returns a capitalized "True" or "False"; you can format that as necessary using ToLower().