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
himanshu huske 7himanshu huske 7 

visualforce task

Write a program to display array of account object record - VFpage + controller code
Biswojeet Ray 11Biswojeet Ray 11

Hello himanshu,


Please try this code. You can use the standard controller to display the records in your visualforce page. 


<apex:page sidebar="false" standardController="Account" recordSetVar="accounts" tabstyle="account">

<apex:pageBlock title="Accounts"> 
    <apex:form >
      <apex:pageBlockTable value="{!accounts}" var="a" id="list">
        <apex:column value="{!}" />
        <apex:column value="{!a.type}" />
        <apex:column value="{!a.billingstreet}"/>
        <apex:column value="{!a.billingCity}" />
        <apex:column value="{!a.billingCountry}" />
        <apex:column value="{!a.billingPostalCode}"/>
        <apex:column value="{!a.createdById}"/>        


I  hope it helps you.

Kindly let me know if it helps you and please mark as Best Answer.

Thanks and Regards,
Deepali KulshresthaDeepali Kulshrestha
Hi himanshu,

Please follow the below code and link with the help of this code and links you can solve your problem, it may be helpful to you.

Apex Controller:
public with sharing class StandardAccountDisplayController{ 
    public List<Account> records {get; set;} 
    public StandardAccountDisplayController(){ 
        records = [select Name, AccountNumber from Account]; 

Visualforce Page:
<apex:page controller="StandardAccountDisplayController"> 
    <apex:pageBlock title="Account List"> 
        <apex:pageBlockTable value="{!records}" var="record"> 
            <apex:column > 
                <apex:facet name="header">Account Name</apex:facet> 
                <apex:outputText value="{!record.Name}"/> 
            <apex:column > 
                <apex:facet name="header">Account Number</apex:facet> 
                <apex:outputText value="{!record.AccountNumber}"/> 


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
Ajay K DubediAjay K Dubedi
Hi Himanshu,
Try below code:
//Controller code
public class AccountsRecords {
    public List<Account> AccountList{get;set;}
    public AccountsRecords(){
        AccountList =new List<Account>();
        AccountList = [SELECT Name,AccountNumber,Type FROM Account LIMIT 10000];

// VF Page
<apex:page controller="AccountsRecords">
    <apex:pageBlock title="Account Details">
        <apex:pageBlockTable value="{!AccountList}" var="accObj">
            <apex:column value="{!accObj.Name}" />
            <apex:column value="{!accObj.AccountNumber}" />
            <apex:column value="{!accObj.Type}"/>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Ajay Dubedi