you can show the record via two ways:- 1. By using Salesforce Record 2. By using Manual RecordIn below example I am using Account record in Salesforce, Custom Controller as shown below :
public class shows20recordsapex {
public List<Account> AccList
{
get;
set;
}
public shows20recordsapex() {
AccList = [Select id,Name,Phone from Account limit 20];
}
}
Visualforce Page as shown below :
<apex:page controller="shows20recordsapex">
<apex:form>
<apex:pageBlock title="20 Records of Accounts">
<table border="2px">
<tr>
<th>Id</th>
<th>Name</th>
<th>Phone</th>
</tr>
<apex:repeat value="{!accList}" var="a" >
<tr>
<td>{! a.Id}</td>
<td>{! a.Name}</td>
<td>{! a.phone}</td>
</tr>
</apex:repeat>
</table>
</apex:pageBlock>
</apex:form>
</apex:page>
Hope it helps you.
Regards, Akshay
2 answers