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
Devaraj 7Devaraj 7 

pagination with example if i want to work with standardsetcontroller any sample example please provide me.

Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Devaraj,

Pagination using standard set controller  May I request you please refer the below link for reference. Hope it will be helpful.

Please mark it as best answer if the information is that question is removed from an unanswered question and appear as a proper solution.

Rahul Kumar
Ajay K DubediAjay K Dubedi

Hi Devaraj,
Below is the code for the same. It working fine in my Org. I have used it for Standard object Contact.

Visualforce Page:-
<apex:page standardController="Contact" recordSetVar="contacts">
    <apex:form >
        <apex:pageBlock title="Contact List" id="contacts_list">
            <apex:selectList value="{! filterId }" size="1">
                <apex:selectOptions value="{! listViewOptions }"/>
                <apex:actionSupport event="onchange" reRender="contacts_list"/>
            <apex:pageBlockTable title="Contacts" value="{!contacts}" var="c">
                <apex:column value="{!c.Name}" />
                <apex:column value="{!c.Email}" />
                <apex:column value="{!c.Account.Name}" />
            <table style="width:100%">
                <td align="left"><apex:outputText >Page {! PageNumber } of {! CEILING(ResultSize/PageSize) }</apex:outputText></td>
                <td align="center">
                    <apex:commandLink action="{! previous }" value="« Previous" rendered="{! hasPrevious }" />
                    <apex:outputText style="color:#ccc" value="« Previous" rendered="{! NOT(hasPrevious) }" />
                    <apex:commandLink action="{! next }" value="Next »" rendered="{! hasNext }" />
                    <apex:outputText style="color:#ccc" value="Next »" rendered="{! NOT(hasNext) }" />
                <td align="right">
                    Records per page:
                    <apex:selectList value="{! PageSize }" size="1">
                        <apex:selectOption itemValue="5" itemLabel="5" />
                        <apex:selectOption itemValue="10" itemLabel="10" />
                        <apex:selectOption itemValue="20" itemLabel="20" />
                        <apex:actionSupport event="onchange" reRender="contacts_list" />


User-added image


@ajay, It worked great for me too, Thanks a lot :-)
Deepali KulshresthaDeepali Kulshrestha
Hi Devaraj,

Pagination is the process of displaying a large number of records and displaying the records on multiple pages within in Salesforce
You can change this page according to your requirement.
<apex:page standardController="Opportunity" extensions="oppoNe" recordSetVar="opportunities">
<apex:pageBlock title="Viewing Opportunities">
<apex:form id="theForm">
<apex:pageBlockSection >
<apex:dataList var="opp" value="{!opportunities}">
<apex:panelGrid columns="4">
<apex:commandLink action="{!first}">FIRST</apex:commandLink>
<apex:commandLink action="{!next}">NEXT</apex:commandLink>
<apex:commandLink action="{!previous}">PREVIOUS</apex:commandLink>
<apex:commandLink action="{!last}">LAST</apex:commandLink>


public class oppoNe {
    public oppoNe(ApexPages.StandardSetController controller) {
I suggest you visit this link, it will help you

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.
Tyler McCartyTyler McCarty
@Deepali But how would you set page size in a custom controller?