+ Start a Discussion
Rajesh SFDCRajesh SFDC 

how to solve this error:Collection size 1,247 exceeds maximum size of 1,000. in visualforce page?

how to solve this error:Collection size 1,247 exceeds maximum size of 1,000. here my requirments i want to display 3000 reocords in visualforce page but i am getting an error,, plz help me frds

<apex:page controller="wrapperController" sidebar="false" >
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>

            <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">

                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <!--apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/-->
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.Phone}" />

                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                    <apex:column value="{!c.Name}" headerValue="Account Name"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>


====================================================================================================controller =========================

public class wrapperController{

    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Account> selectedAccounts{get;set;}
    string currentrecordid= ApexPages.currentPage().getParameters().get('id');

    public wrapperController()
        if(wrapAccountList == null)
            wrapAccountList = new List<wrapAccount>();
            LIST<Account> ac=new list<Account>();
            map<string,string> resultmap=new map<string,string>();
           // integer countrecord=[select count() from account  ];
            ac=[select Id, Name, Website, Phone from Account ];
            for(Account a: ac )
                wrapAccountList.add(new wrapAccount(a));

    public void processSelected()
    selectedAccounts = new List<Account>();

        for(wrapAccount wrapAccountObj : wrapAccountList)
            if(wrapAccountObj.selected == true)

    public class wrapAccount
        public Account acc {get; set;}
        public Boolean selected {get; set;}

        public wrapAccount(Account a)
            acc = a;
            selected = false;
Chidambar ReddyChidambar Reddy
I think the following link may help you

Try to use like this if you need to view only records

<apex:page controller="sample" readOnly="true">

It will bring upto 1 million records but we can't able to do some process of insert,update.
You can try readonly attribute before pagination code..

Thank You
There are workarounds as mentioned by chidambaram above.
However, larger sizes of list would have a negative effect on the VF page as it will take a lot of time to load the page.

Satish Kumar
Hi Rajesh,
       Use readonly="true" attribute of <apex:page> tag or else use pagination to display records in visualforce page.
Please let me know if u need further help.