I don't know why the below code is not working , next and previous button.
Any help would be highly appreciated??
VF Page :-
<apex:page controller="paginationcls" >
   <apex:pageBlockTable value="{!paginateAccts}" var="acc" id="pbt">

       <apex:column value="{!acc.Name}"  />
       <apex:column value="{!acc.Phone}"/>


        <apex:commandButton value="Next" action="{!GoNext}" reRender="pbt"/>
        <apex:commandButton value="Previous" action="{!GoPrevious}" reRender="pbt"/>

Apex Class:-
public class paginationcls {
    public ApexPages.StandardSetController setCon{set;get;}
    public List<Account> paginateAccts{set;get;}
    public paginationcls(){
       setCon= new ApexPages.StandardSetController([select id,name,phone from Account limit 20]); 

    public void GoNext(){

    public void GoPrevious(){

1 Answer 1


You never update paginateAccts. You need to reset that variable each time you change a page, in the GoNext() and GoPrevious(). Otherwise, you're simply re-rendering the same list each time.

  • ,thnx for ur awesome response but i dont know how to reset the page on calling next method...i dont think any standard method is given in Standardsetcontroller class
    – SFDCTashan
    Apr 10, 2020 at 15:51
  • got the answer from your hint... paginateAccts=(List<Account>)setCon.getRecords(); This line i need to write again in GoNext() method it will work. Let me try it for Previuos method also.
    – SFDCTashan
    Apr 10, 2020 at 15:54
  • Thnx David for ur help.
    – SFDCTashan
    Apr 10, 2020 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.