How to check whether a field value in Visualforce page is blank or null?

How to check whether a field value in Visualforce page is blank or null?

Sample Code:

Visualforce page:

<apex:page controller="Sample">
    <apex:pageblock >
        <apex:pageBlockTable value="{!MembList}" var="M">
            <apex:column value="{!M.Name}"/>
            <apex:column >
                <apex:outputText value="{! IF((M.Age__c == null), 'NA', M.Age__c) }"/>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageblock>
</apex:page>

Apex Controller:

public class Sample {  
    public List<Member__c> MembList {get;set;}
   
    public Sample() {
        MembList = [SELECT Name, Age__c FROM Member__c];
    }           
}

Output:

Leave a Reply