+ Start a Discussion
bhanu challengebhanu challenge 

would u plz tel how to write code in vf

We have 3 objects Account, Contact, Opportunity.   In a VF page, we need to display the names of contact & Opportunity which are related to Account.
Best Answer chosen by bhanu challenge
Amit Chaudhary 8Amit Chaudhary 8
Please try below code
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
    <apex:pageBlock >
          <apex:repeat value="{!accounts}" var="a">
<apex:pageBlockSection title="{!a.name}"></apex:pageBlockSection>
  <apex:relatedList list="Contacts" subject="{!a.Id}"/>
<apex:relatedList list="Opportunities" subject="{!a.Id}" />
</apex:repeat>      
     </apex:pageBlock>
</apex:page>
Let us know if this will help you