In below example “Student” is the custom Master object, and “Project” is the custom Child object.
Controller:
public class SampleController { //Contact List Variable public List<Student__c> stuList {get;set;} //Constructor public SampleController(){ stuList = [SELECT Id, Name, (SELECT Id, Name FROM Projects__r) FROM Student__c LIMIT 10]; } }
Visualforce Page:
<apex:page controller="SampleController"> <table> <apex:repeat value="{!stuList}" var="stu"> <tr> <td><apex:outputText value="{!stu.Name}"/></td> <apex:repeat value="{!stu.Projects__r}" var="pro"> <td><apex:outputText value="{!pro.Name}"/></td> </apex:repeat> </tr> </apex:repeat> </table> </apex:page>