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
Lavanya Ponniah 3Lavanya Ponniah 3 

Accounts and its associated Contacts on VF page

Hi,
I need to display like below.
-------------------------------------
Account Name1
    Contact1
    Contact2
Account Name2
    Contact1
AccountName3
    Contact1
-------------------------- etc
Like this per each Account Name i need to display associated contacts below that account as shown above.
Please  send sample code to achieve this.
Avidev9Avidev9
I think this can be easily achieved using standard controller. This should be pretty easy
<apex:page standardController="Account" recordSetVar="accounts">
    <apex:repeat value="{!accounts}" var="acc">
        {!acc.Name}
        <br/>
        <ul>
            <apex:repeat value="{!acc.Contacts}" var="con">
                <li>{!con.Name}</li>
            </apex:repeat>
        </ul>
    </apex:repeat>
</apex:page>