+ 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>