Retrieving child record from parent record in Salesforce

Visualforce page:

<apex:page controller="sample">
    <apex:pageBlock >
       <apex:pageBlockTable value="{!mem}" var="m">
            <apex:column value="{!m.Name}"/>
            <apex:repeat value="{!m.Interest__r}" var="i">
                <apex:column value="{!i.Name}"/>

Apex Controller:

public class sample
    public List<Member__c> mem {get;set;}
    public sample()
        String soql = 'SELECT Name, (SELECT Name FROM Interest__r) FROM Member__c LIMIT 5';
        mem = Database.Query(soql);


No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit