How do I sort a bool column?
How do I sort a bool column?
I am using ASP.NET MVC and grabbing columns from a SQL table. In C# these are bools but in SQL they are bits. The column in the Data Table is showing check boxes which are blanks for "False" (0) and checked for "True" (1).
However, the standard sort is not changing the order of these checkboxes. Is there a way to switch the order of these boolean values? I have searched everywhere I cannot seem to find another forum with this situation. Thank you for any help you can give on this.
Answers
I think I have the same situation: My mysql database fields are Tinyint(1) which is used to save boolean values (0 and 1).
If I click to sort it works fine.
Something else must be wrong I guess.
Just post some code and someone can take a look (probably not me because I am using MySQL, Javascript and PHP...).
This is my entire Javascript code; maybe that helps a little
Assuming you are using live dom elements (i.e.
<input type="checkbox">
) then you need to use a technique like that shown in this example.Allan