Fixing A Blue Filled Checkbox in .Net

If you ever seen the above check mark, you are probably wondering what the heck is going on. First off it’s not checked or checked, some in between state where it’s just filled with a blue square. Second off you even, most likely, have a variable bound to it, and yet it still displays as this!

The issue is that the variable that you have it bound to is null. This is the default way to show null in a check box, not just an empty square like you would expect such as when the value is equal to false. There is a solution you can try. If you are binding to a database and using SQL, you can use the following code to set all the values to null, then add a default of zero to the column to prevent the blue box from showing up.

UPDATE tableName
SET columnName= 0
WHERE columnName= null

ADD DEFAULT 0 FOR columnName;

If you are not using SQL, then check in visual studio for what ever data object you are binding to, and set it’s default value to zero. (I’m not going to give a tutorial on each way since there are a few).

Hope this helps, and happy coding!

Releated Post

Leave a Reply

%d bloggers like this: