I am displaying the pagination using standardsetController. And it is working but when i try to change the value in my inputtest and i am clicking the next button it is showing error that

System.VisualforceException: Modified rows exist in the records collection!

Is it is not possible to change the value of the displaying record by using pagination. Please guide me the proper way to get the solution. Here is my class

    public ApexPages.StandardSetController setCon{
        if(setCon == null){
           limits = 5;
           String queryString = 'SELECT Name, Id, Languages__c FROM Contact WHERE name != null'; 
           setCon = new ApexPages.StandardSetController(DataBase.getQueryLocator(queryString));
           recNum = setCon.getResultSize();
           SYSTEM.DEBUG('Inside Apex Pages Standard set Controller ' + setCon );

        clone_cont_lst = setCon.getRecords();
        for(Contact c:  clone_cont_lst){
            contMap.put(c.id, c);
        return setCon;



public pageReference refresh(){
    setCon = null;
    return null;


public List<Contact> getContact(){

    List<Contact> conLst = new List<Contact>();
    for(Contact c: (List<Contact>)setCon.getRecords()){



    counter = recNum / 5;        
    return conLst;
  public void nextbtn(){

my vf page

<apex:form >
 <apex:dataTable value="{!Contact}" var="ac" id="paginationID">
      <apex:column headerValue="Name">
          <apex:outputField value="{!ac.Name}"/>
      <apex:column headerValue="Id">
          <apex:outputField value="{!ac.Id}"/>
      <apex:column headerValue="Languages">
          <apex:inputField value="{!ac.Languages__c}"/>

  <apex:commandButton value="FIRST" action="{!fstbtn}" disabled="{!prv}" reRender="paginationID,pgno"/>
  <apex:commandButton value="PRE" action="{!prvbtn}" disabled="{!prv}" reRender="paginationID,pgno"/>
  <apex:commandButton value="NXT" action="{!nextbtn}" disabled="{!nxt}" reRender="paginationID,pgno"/>
  <apex:commandButton value="END" action="{!endbtn}" disabled="{!nxt}" reRender="paginationID,pgno"/>
  <br/><apex:outputText >No of pages {!counter}</apex:outputText>
       <apex:outputText id="pgno">of current page- {!setCon.PageNumber} </apex:outputText>


please guide me what i am doing wrong.


If you study your controller and your VF page code, you have no update or save code in either one. Even if you did, neither is related to your pagination code. You would need to link update code to your pagination code. If you did that, you'd also want to raise an alert! asking if the user wanted to save the changes they'd made.

| improve this answer | |
  • this error occurs when i click on my next button after making change in my record. Yes the user need to save the change, his requirement is if he made the change in pg 1 and hit next and go to page 2 and then 3 and make change on 3 and when he come back to pg 1 the changed value should be there before saving .. that mean he need it to hold temp before save. As ef now he need to update the current records according to the change he make. – Anu Jul 10 '14 at 16:50
  • If you look at your controller you'll see contMap.put(c.id, c) which holds a map of what's returned from your queries. Your controller doesn't have any means of holding changes your user makes to pagination views. You'd need to add that functionality to it in order to do what you're asking about. – crmprogdev Jul 10 '14 at 16:57
  • As u mentioned about the map i am using i have commented it but i am still facing the same issue. I used map to trace is the records see before and does there any update done. I have not completed it before that i tested it i found this issue. Do you have any idea over this. If i click next button without updating the record it has no problem but if we change this i am facing this issue. Please guide me. – Anu Jul 10 '14 at 17:23
  • You really need to look at the documentation. If I'm not mistaken, those records are also part of a get related to your query string locator. That puts a lock on those records. Until the lock is released, they can't be modified outside that querystring/controller. – crmprogdev Jul 10 '14 at 17:57

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.