CheckBoxField in GridView does not bind to string field in database
How do I bind a CheckBoxField in my GridView with a base db field which is a string. The string is either "1" or "0", but still the GridView will not readily bind to it. What am I doing. What is the best way to set the checkbox in the GridView and get it and set the row in the database (or underlying data source).
+1
source to share
3 answers
CheckBoxField is associated with a boolean. You can either convert the string to a boolean expression in the binding expression, or apply it in the db return.
It would make more sense for the database to store the state of the checkbox as a bit, not a string. Then this problem will disappear completely.
Of course, if you need to store the third gray state, it complicates things a bit, but you can still store the state as an int.
+1
source to share