+ Start a Discussion
Chinnu ChinnuChinnu Chinnu 

Develop a vf page and display the account with corresponding related contacts

Rounak SharmaRounak Sharma
hello chinnu,
Please check the below url 
I am sure it will help you.
Please let me know if still you have any doubt
Khan AnasKhan Anas (Salesforce Developers) 
Hi Chinnu,

Greetings to you!

Please refer to the below links which might help you further with the above requirement.





I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Chinnu ChinnuChinnu Chinnu
Hey, This is my code..
VF page:
<apex:page controller="ContactsVisualforceController" standardStylesheets="false">
    <apex:pageBlock title="Contacts List">
        <apex:repeat value="{!displayAccounts}" var="acc">
                <dt>Account Name:</dt>
                <dd><apex:outputText value="{!acc.Name}"/></dd> 
            <dl><dt>Contact Names:</dt></dl>

            <apex:pageblocktable value="{!acc.Contacts}" var="cont">
                <apex:column value="{!cont.firstname}"/>
                <apex:column value="{!cont.lastname}"/>


public class ContactsVisualforceController {
    public list<Account> displayAccounts {get; set;}
    public ContactsVisualforceController(){
        displayAccounts = [select id,name,(select id,name,firstname,lastname from Contacts) from Account];

This is working fine ok.. But now I want to display as Block means

AccountName1 here          All related Contacts For that AccountName1 should display here
AccountName2 here          All related Contacts For that AccountName2 should display here
AccountName3 here          All related Contacts For that AccountName3 should display here

like this I want to display 10 records in one page and another 10 records on another page so pagination we have to use..
So I want how can we do that can anyone please tell me..
Rounak SharmaRounak Sharma
Hello chinnu,

Please refer the below url for it

Please let me know if it helps.
Chinnu ChinnuChinnu Chinnu
Hi Rounak,
Here I'm using custom controller in Vf page so for that I want...
Rounak SharmaRounak Sharma
i don't think you can do pagination without using standardList controller. Go through the trailhead and it will be more clear to you.