anusha(salesforce developer)

Wednesday, 14 September 2016

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:


No comments:

Post a Comment