function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

how to display account records?

i want to display only 5 Account records using custom controller after that if i click any record, it need to show the detail page of that account record..

Help me with the code...
Best Answer chosen by Chinnoy
sandhya reddy 10sandhya reddy 10
Hi Venkat,

please find below code
vf page

<apex:page controller="Task7Controller" >
  <apex:form >
   <apex:pageBlock >
     <apex:pageBlockTable value="{!btls}" var="bt">
      <apex:column >    
         <apex:commandLink action="{!getDetails}" value="{!}"> 
         <apex:param name="aId" value="{!bt.Id}" assignTo="{!aID}"/>      


public class Task7Controller {
public List<Account> btls{set; }   
    public List<Bottle__c> getbtls(){
     List<Account> mbt= new List<Account>();
       mbt = [Select Name from Account limit 5];
     // PageReference pr =new PageReference('/' + aID);
return mbt;
public PageReference getDetails()
  PageReference pr =new PageReference('/' + aID);
return pr;

public string aID{get;set;}

Please let us know if this helps you.

Thanks and Regards