[SalesForce] How to display a variable as checkbox in visual force page

I'm trying to read an integer value from the controller and render it as a checkbox in my Visual force page. If 1 render it as checked and if 0 render it as unchecked. I get a compilation error Unknown property 'readValue'. If I simply did a apex:inputcheckbox selected="true" it doesn't work either.

    <apex:datatable value="{!classRows}" var="class" id="classTable"
        <apex:inputhidden value="{!class[column01.FieldName]}" id="hvl01" rendered="true" />
        <apex:variable var="readValue" value="{!IF(class[column01.FieldName]=1,true,false)}" id="testread" />
        <apex:outputtext value="{!readValue}" />
        <apex:inputcheckbox selected="{!readValue}" id="chk01" />
     </apex:datatable>      

Best Answer

Please make sure that you have a boolean attribute defined in your controller named readValue.

Controller:

...
public Boolean readValue {get;set;}
...

Also in your page set the value of the input checkbox as follows:

Page:

...
<apex:inputCheckbox value="{!readValue}">
...