You need to sign in to do that
Don't have an account?
Tony66
Display list of records in visualforce using SOQL query
Hello guys, I have a vf page on workorder object. When I open the vf page on a wo record whose account name is ABC and po number (custom field) is 123 for example, I want to display a list of all the work orders who have the same account and the po number. How do I query and display these set of records as a custom related list on the visualforce page?
Hi Tony,
Whenever you want to display something in a visual force page you have to write get method or get property
like public list<Account> accs {get;set;}
try this:
Vf Page
public class ClassRetrieve {
public list<Account> accs {get;set;}
public ClassRetrieve()
{
accs = [Select Id, Name, (Select Id, Name From Contacts) From Account];
}
}
Class :
<apex:page controller="ClassRetrieve">
<apex:pageBlock >
<apex:pageBlockTable value="{!accs}" var="a">
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Id}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks.