function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Uday MenkurkarUday Menkurkar 

apex if else

How do I use "IF/ELSE" logic (or something better) to avoid displaying a pageblock completely if the related list is empty.  In the code below, a pageblock gets displayed that shows a certain list that is related list.  It is possible that the related list is empty.  The problem is that even if the relatedList has no data, an empty block "Higher Probability" gets displayed.  How do I avoid displaying the pageBlock completely if the relatedList is empty?

Thanks
<apex:pageBlock title="Higher Probability">
        <apex:pageBlockTable value="{! highLikelihoodDeals }" var="ds">
            <apex:column value="{! ds.Issuer__c }"/>
            <apex:column headerValue="Bids Due" value="{! ds.Circle_Due_Date__c }"/>
            <apex:column headerValue="Maturities">            
                    <apex:pageBlockTable value="{!ds.Tranches__r}" var="val">
                        <apex:column headerValue="Tenor" value="{! val.name }"/>
                    </apex:pageBlockTable>
            </apex:column>
            <apex:column headerValue="Comments" value="{! ds.Deal_Description__c }"/>
        </apex:pageBlockTable>
    </apex:pageBlock>

 
mohdAnasmohdAnas

Hi Uday,

try using rendered="{! highLikelihoodDeals.size>0}" in page block tag

<apex:pageBlock title="Higher Probability" rendered="{! highLikelihoodDeals.size>0}">
        <apex:pageBlockTable value="{! highLikelihoodDeals }" var="ds" >
            <apex:column value="{! ds.Issuer__c }"/>
            <apex:column headerValue="Bids Due" value="{! ds.Circle_Due_Date__c }"/>
            <apex:column headerValue="Maturities">            
                    <apex:pageBlockTable value="{!ds.Tranches__r}" var="val">
                        <apex:column headerValue="Tenor" value="{! val.name }"/>
                    </apex:pageBlockTable>
            </apex:column>
            <apex:column headerValue="Comments" value="{! ds.Deal_Description__c }"/>
        </apex:pageBlockTable>
    </apex:pageBlock>

 
Uday MenkurkarUday Menkurkar
Worked like a magic!! Thanks for your help.