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
Agent Comms 7Agent Comms 7 

Issue with Pagination for Wrapper Class

i have built a pagination for wrapper class,my requirement is after clicking the next link the previous link will activate , similarly when i will be on last page the next link will be deactivate.


my controller:-

    public with sharing class acc_controller {
    
    public  List<Account> accList{get;set;}
    public  List<AccWrapper> accWrapList{get;set;}
    public  List<AccWrapper> accWrapList2{get;set;}
    public  List<AccWrapper> accWrapList3{get;set;}
    
    //public Integer cust_limit{get;set;}
    public  Integer cust_offset{get;set;}
    public  Integer cust_fixed_offset{get;set;}
    public  Boolean showFinalResult{get;set;}
    
    public Class AccWrapper
    {
        public Account acc{get;set;}
        public Boolean flag{get;set;}
        public AccWrapper(Account acc)
        {
            this.acc=acc;
            this.flag=false;
        }
    }
        public acc_controller(ApexPages.StandardController controller) {
            
        //cust_limit=1;
        showFinalResult=false;
        cust_fixed_offset=2;
        cust_offset=0;
        accList=new List<Account>();
        accWrapList=new List<AccWrapper>();
        accWrapList2=new List<AccWrapper>();
        accList=[select id,name from account limit 100];
        
        Integer count=0;
        for(Account accObj:accList)
        {
            accWrapList.add(new AccWrapper(accObj));
            if(count<cust_fixed_offset)
            {
            accWrapList2.add(new AccWrapper(accObj));
            count++;
            }
            
        }
    }
    
    
    
    public void saveList()
    {
        
        for(AccWrapper accWrapObj1:accWrapList)
        {
            for(AccWrapper accWrapObj2:accWrapList2)
            {
                if(accWrapObj2.acc.Id==accWrapObj1.acc.Id)
                {
                   accWrapObj1.flag=accWrapObj2.flag; 
                }
            }
        }
    }
    
    public  void next()
    {
        accWrapList2=new List<AccWrapper>();
        
        cust_offset+=cust_fixed_offset; 
        if(cust_offset>accWrapList.size()-1)
        {
            cust_offset=accWrapList.size()-1;
            
        }
        Integer counter=0;
        for(Integer i=cust_offset;i<accWrapList.size();i++)
        {
            if(counter<cust_fixed_offset)
            {
             accWrapList2.add(accWrapList[i]);
             counter++;
            }
            else
            {
            break;
            }
            
        }
       
    }
    
    
    public  void previous()
    {
        accWrapList2=new List<AccWrapper>();
        cust_offset-=cust_fixed_offset;
        if(cust_offset<1)
        {
            cust_offset=0;
            
        }
        Integer counter=0;
        for(Integer i=cust_offset;i<accWrapList.size();i++)
        {
            if(counter<cust_fixed_offset)
            {
             accWrapList2.add(accWrapList[i]);
             counter++;
            }
            else
            {
            break;
            }
            
        }
            
    
    }
    
    public void first()
    {
    }
    
    public void last()
    {
    }
    
    public void Process()
    {
         
         accWrapList3=new List<AccWrapper>();
         for(AccWrapper accWrapObj1:accWrapList)
         {
             if(accWrapObj1.flag)
             {
             accWrapList3.add(accWrapObj1);
             }
         }
         showFinalResult=true;
        
    }

}

myVfpage:-

<apex:page standardController="Account" extensions="acc_controller">
<apex:form >
<apex:actionstatus startText="processing..." id="statusBar"></apex:actionstatus>
<apex:pageblock >
<!--<apex:commandLink value="First"/>-->
     <apex:commandLink value="Next" reRender="pTable" status="statusBar" action="{!next}"/>&nbsp;&nbsp;
     <apex:commandLink value="Previous" reRender="pTable" status="statusBar" action="{!previous}"/>
     <!--<apex:commandLink value="Last"/>     -->
     
     
     <apex:commandbutton value="Process" action="{!Process}" rerender="finalResult" status="statusBar"/>
     <apex:outputPanel id="pTable">
     <apex:pageblockTable value="{!accWrapList2}" var="a" >
     <apex:column headerValue="Select">
         <apex:inputCheckbox value="{!a.flag}">
         <apex:actionSupport event="onclick" rerender="pTable" status="statusBar" action="{!saveList}"/>
         </apex:inputCheckbox>
     </apex:column>
     <apex:column value="{!a.acc.name}"/>
     
     </apex:pageblockTable>
     
     </apex:outputPanel>
     
     <!--<apex:commandLink value="First"/>-->
     <apex:commandLink value="Next" reRender="pTable" status="statusBar" action="{!next}"/>&nbsp;&nbsp;
     <apex:commandLink value="Previous" reRender="pTable" status="statusBar" action="{!previous}"/>
     <!--<apex:commandLink value="Last"/>     -->
     
     <apex:pageblock >
     <apex:outputPanel id="finalResult">
     <apex:pageBlockTable value="{!accWrapList3}" var="ac" rendered="{!showFinalResult}">
     <apex:column value="{!ac.acc.name}"/>
     </apex:pageBlockTable>
     </apex:outputPanel>
         
     </apex:pageblock>
     
 </apex:pageblock>
</apex:form>
</apex:page>



please help me...
please run this code and please share the solution.
i am new to salesforce and this requirement is in high priority.
Best Answer chosen by Agent Comms 7
badrul Hassanbadrul Hassan
<apex:page controller="ContactsTable1" sidebar="false" showHeader="false">
    <apex:form id="myform"> 
   <apex:actionFunction name="refreshPageSize" action="{!refreshPageSize}" status="fetchStatus" reRender="pbId"/>
        <apex:pageblock id="pbId" >
        
         
                <apex:pageBlockSection columns="2" > 
                
               
                
                <apex:pageblock >   
            <!-- In our table, we are displaying the Contact records --> 
         <apex:pageblockButtons location="Top">
     <apex:commandButton value="Processed" action="{!clickMe}" /> 
    </apex:pageblockButtons>       
          <apex:pageblocktable value="{!Contact}" var="cc" id="test"  > 
                <apex:column headerValue="Choose Contact"> 
                <apex:inputCheckbox value="{!cc.bool}"/> </apex:column> 
                <apex:column value="{!cc.con.Name}"/> 
                <apex:column value="{!cc.con.Email}"/> 
          </apex:pageblocktable> 
          
                <apex:pageBlockButtons location="Bottom"> 
                <apex:commandButton value="First" action="{!Setcon.First}" disabled="{!NOT(Setcon.hasPrevious)}" reRender="myform" /> 
                    <apex:commandButton value="Previous" action="{!Setcon.Previous}" disabled="{!NOT(Setcon.hasPrevious)}" reRender="myform" /> 
                    <apex:commandButton value="Next" action="{!Setcon.Next}" disabled="{!NOT(Setcon.hasNext)}" reRender="myform" /> 
                    <apex:commandButton value="Last" action="{!Setcon.Last}" disabled="{!NOT(Setcon.hasNext)}" reRender="myform" /> 
                </apex:pageBlockButtons> 
                  <apex:selectList value="{!size}" multiselect="false" size="1" onchange="refreshPageSize();">
                    <apex:selectOptions value="{!ContactsTables}"/>
                </apex:selectList>
              
               
                </apex:pageblock>
                <apex:pageBlock >
          
                    <apex:outputPanel rendered="{!display}"> 
                        <apex:pageblocktable value="{!selectedList}" var="w" rows="1" columns="2" > 
                        <apex:column value="{!w.Name}"/> 
                        <apex:column value="{!w.Email}"/> 
                    </apex:pageblocktable> 
                    
                    <apex:commandButton value="Done"/>
                    
                     
                </apex:outputPanel> 
             
           
      </apex:pageblock>
    </apex:pageBlockSection>
      </apex:pageblock> 
        
    </apex:form> 
</apex:page>



Apex Page:---



Public class ContactsTable1 { 
   
    public Integer size { get; set; } 
    Public List<WrapperContactWrapper> wrapperlist; 
    Public Integer noOfRecords{get; set;} 
    Map <id,Contact> SelectedcontactMap = new Map <id,Contact>(); 
    public boolean display{get;set;} 
    public list<Contact> selectedList {get;set;} 
     public List<SelectOption> ContactsTables{get;set;}
    Public class WrapperContactWrapper { 
        Public Contact con{get;set;} 
        Public boolean bool{get;set;} 
        public WrapperContactWrapper(Contact c,boolean bool) { 
            this.con = c; this.bool = bool; 
        }
    }

 
 public ContactsTable1 (){
        size=10;
        ContactsTables= new List<SelectOption>();
        ContactsTables.add(new SelectOption('5','5'));
        ContactsTables.add(new SelectOption('10','10'));
        ContactsTables.add(new SelectOption('20','20'));
        ContactsTables.add(new SelectOption('50','50'));
        ContactsTables.add(new SelectOption('100','100'));
    }
    public ApexPages.StandardSetController Setcon { 
        get { 
        if(Setcon == Null)
         { 
            Setcon = new ApexPages.StandardSetController(Database.getQueryLocator([Select Name,Accountid,Email,MobilePhone,LeadSource from Contact])); 
    
            setCon.setpagesize(size); 
            noOfRecords = setCon.getResultSize(); } 
            return Setcon; 
        }
        set;
    } 
 
 public PageReference refreshPageSize() {
         Setcon.setPageSize(size);
         return null;
    }
    
    Public List<WrapperContactWrapper> getContact() { 
        getSelectedContact();
        wrapperlist = new List <WrapperContactWrapper>(); 
        
        for(Contact cc : (List<contact>)Setcon.getRecords()) { 
            if( SelectedcontactMap .ContainsKey(cc.id)) { 
                wrapperlist.add (new WrapperContactWrapper(cc,true));
            } else { 
            wrapperlist.add(new WrapperContactWrapper(cc,false));
            }
        } 
        return wrapperlist;
    }
    
    public void getSelectedContact(){ 
        if(wrapperlist!=null) { 
            for(WrapperContactWrapper wr:wrapperlist) { 
                if(wr.bool == true) { 
                    SelectedcontactMap.put(wr.con.id,wr.con); 
                } else { 
                    SelectedcontactMap.remove(wr.con.id);      
                }      
            }
        }
    }
          
   public void clickMe() { 
        display = true; 
        getSelectedContact(); 
        selectedList = SelectedcontactMap.values();
        getContact(); 
}
    
    public integer pageNumber { 
        get { 
            return Setcon.getPageNumber();
        }
        set;
    }
}

 

All Answers

Deepak GulianDeepak Gulian
//This is for contact object
<apex:page controller="ContactsTable">
    <apex:form id="myform"> 
        <apex:pageblock >
            <apex:pageBlockButtons location="Top"> 
                <apex:commandButton value="Processed" action="{!clickMe}" /> 
            </apex:pageBlockButtons> 
            <!-- In our table, we are displaying the Contact records --> 
            <apex:pageblocktable value="{!Contact}" var="cc" > 
                <apex:column headerValue="Choose Contact"> 
                <apex:inputCheckbox value="{!cc.bool}"/> </apex:column> 
                
                <apex:column value="{!cc.con.Name}"/> 
                <apex:column value="{!cc.con.Accountid}"/> 
                <apex:column value="{!cc.con.Email}"/> 
                <apex:column Value="{!cc.con.MobilePhone}"/> 
                <apex:column value="{!cc.con.LeadSource}"/> 
            </apex:pageblocktable> 
            <apex:pageBlockButtons location="Bottom"> 
                <apex:commandButton value="First" action="{!Setcon.First}" disabled="{!NOT(Setcon.hasPrevious)}" reRender="myform" /> 
                    <apex:commandButton value="Previous" action="{!Setcon.Previous}" disabled="{!NOT(Setcon.hasPrevious)}" reRender="myform" /> 
                    <apex:commandButton value="Next" action="{!Setcon.Next}" disabled="{!NOT(Setcon.hasNext)}" reRender="myform" /> 
                    <apex:commandButton value="Last" action="{!Setcon.Last}" disabled="{!NOT(Setcon.hasNext)}" reRender="myform" /> 
                </apex:pageBlockButtons> 
                
                <apex:outputText >Page Number {!pageNumber} </apex:outputText> 
            </apex:pageblock> 
            
            <apex:pageblock > 
                <apex:outputPanel rendered="{!display}"> 
                    <apex:pageblocktable value="{!selectedList}" var="w" > 
                        <apex:column value="{!w.Name}"/> 
                        <apex:column value="{!w.Accountid}"/> 
                        <apex:column value="{!w.Email}"/> 
                        <apex:column value="{!w.MobilePhone}"/> 
                        <apex:column value="{!w.LeadSource}"/> 
                    </apex:pageblocktable> 
                </apex:outputPanel> 
            </apex:pageblock> 
    </apex:form> 
</apex:page>
//Controller
Public class ContactsTable { 

    public String size { get; set; } 
    Public List<WrapperContactWrapper> wrapperlist; 
    Public Integer noOfRecords{get; set;} 
    Map <id,Contact> SelectedcontactMap = new Map <id,Contact>(); 
    public boolean display{get;set;} 
    public list<Contact> selectedList {get;set;} 

    Public class WrapperContactWrapper { 
        Public Contact con{get;set;} 
        Public boolean bool{get;set;} 
        public WrapperContactWrapper(Contact c,boolean bool) { 
            this.con = c; this.bool = bool; 
        }
    }

    public ApexPages.StandardSetController Setcon { 
        get { if(Setcon == Null) { 
            Setcon = new ApexPages.StandardSetController(Database.getQueryLocator([Select Name,Accountid,Email,MobilePhone,LeadSource from Contact])); 
    
            setCon.setpagesize(10); 
            noOfRecords = setCon.getResultSize(); } 
            return Setcon; 
        }
        set;
    } 
 
    Public List<WrapperContactWrapper> getContact() { 
        getSelectedContact();
        wrapperlist = new List <WrapperContactWrapper>(); 
        
        for(Contact cc : (List<contact>)Setcon.getRecords()) { 
            if( SelectedcontactMap .ContainsKey(cc.id)) { 
                wrapperlist.add (new WrapperContactWrapper(cc,true));
            } else { 
            wrapperlist.add(new WrapperContactWrapper(cc,false));
            }
        } 
        return wrapperlist;
    }
    
    public void getSelectedContact(){ 
        if(wrapperlist!=null) { 
            for(WrapperContactWrapper wr:wrapperlist) { 
                if(wr.bool == true) { 
                    SelectedcontactMap.put(wr.con.id,wr.con); 
                } else { 
                    SelectedcontactMap.remove(wr.con.id);      
                }      
            }
        }
    }
          
    public void clickMe() { 
        display = true; getSelectedContact(); 
        selectedList = SelectedcontactMap.values();
    }
    
    public integer pageNumber { 
        get { 
            return Setcon.getPageNumber();
        }
        set;
    }
}


 
Agent Comms 7Agent Comms 7
Thank you Deepak.
Agent Comms 7Agent Comms 7
hi, deepak
thank you so much. the code is working according to my requirement.. 
but  one more thing , when i click the "Processed" button, its showing me the selected records, at the same time i want to refresh the checkbox table, which is not occuring now.
how i will do this?
Deepak GulianDeepak Gulian
Update Clickme function in your controller
public void clickMe() { 
        display = true; 
        getSelectedContact(); 
        selectedList = SelectedcontactMap.values();
        wrapperlist = null;
        SelectedcontactMap.clear();
        getContact(); 
}
Agent Comms 7Agent Comms 7
thank you ... it's working.
Deepak GulianDeepak Gulian
Could you please mark it as best answer it you found it helpful!
Agent Comms 7Agent Comms 7
hi, please help...
i have used the above code, but i have some requirement like-
Implement functionality where we can give user an option to select No of records he wants to view on one Page . Options (5 ,7, 10) and accordingly the links (Next , previous) should be enabled for the User.  how i will do that?
please help
 
Agent Comms 7Agent Comms 7
please give me the solution, how i give a dropdown in my page where user can give the option and can see no of records he wants.
please help..
badrul Hassanbadrul Hassan
Hi  Agent Comms 7,

Implement this code.

Could you please mark it as best answer it you found it helpful!
badrul Hassanbadrul Hassan
<apex:page controller="ContactsTable1" sidebar="false" showHeader="false">
    <apex:form id="myform"> 
   <apex:actionFunction name="refreshPageSize" action="{!refreshPageSize}" status="fetchStatus" reRender="pbId"/>
        <apex:pageblock id="pbId" >
        
         
                <apex:pageBlockSection columns="2" > 
                
               
                
                <apex:pageblock >   
            <!-- In our table, we are displaying the Contact records --> 
         <apex:pageblockButtons location="Top">
     <apex:commandButton value="Processed" action="{!clickMe}" /> 
    </apex:pageblockButtons>       
          <apex:pageblocktable value="{!Contact}" var="cc" id="test"  > 
                <apex:column headerValue="Choose Contact"> 
                <apex:inputCheckbox value="{!cc.bool}"/> </apex:column> 
                <apex:column value="{!cc.con.Name}"/> 
                <apex:column value="{!cc.con.Email}"/> 
          </apex:pageblocktable> 
          
                <apex:pageBlockButtons location="Bottom"> 
                <apex:commandButton value="First" action="{!Setcon.First}" disabled="{!NOT(Setcon.hasPrevious)}" reRender="myform" /> 
                    <apex:commandButton value="Previous" action="{!Setcon.Previous}" disabled="{!NOT(Setcon.hasPrevious)}" reRender="myform" /> 
                    <apex:commandButton value="Next" action="{!Setcon.Next}" disabled="{!NOT(Setcon.hasNext)}" reRender="myform" /> 
                    <apex:commandButton value="Last" action="{!Setcon.Last}" disabled="{!NOT(Setcon.hasNext)}" reRender="myform" /> 
                </apex:pageBlockButtons> 
                  <apex:selectList value="{!size}" multiselect="false" size="1" onchange="refreshPageSize();">
                    <apex:selectOptions value="{!ContactsTables}"/>
                </apex:selectList>
              
               
                </apex:pageblock>
                <apex:pageBlock >
          
                    <apex:outputPanel rendered="{!display}"> 
                        <apex:pageblocktable value="{!selectedList}" var="w" rows="1" columns="2" > 
                        <apex:column value="{!w.Name}"/> 
                        <apex:column value="{!w.Email}"/> 
                    </apex:pageblocktable> 
                    
                    <apex:commandButton value="Done"/>
                    
                     
                </apex:outputPanel> 
             
           
      </apex:pageblock>
    </apex:pageBlockSection>
      </apex:pageblock> 
        
    </apex:form> 
</apex:page>



Apex Page:---



Public class ContactsTable1 { 
   
    public Integer size { get; set; } 
    Public List<WrapperContactWrapper> wrapperlist; 
    Public Integer noOfRecords{get; set;} 
    Map <id,Contact> SelectedcontactMap = new Map <id,Contact>(); 
    public boolean display{get;set;} 
    public list<Contact> selectedList {get;set;} 
     public List<SelectOption> ContactsTables{get;set;}
    Public class WrapperContactWrapper { 
        Public Contact con{get;set;} 
        Public boolean bool{get;set;} 
        public WrapperContactWrapper(Contact c,boolean bool) { 
            this.con = c; this.bool = bool; 
        }
    }

 
 public ContactsTable1 (){
        size=10;
        ContactsTables= new List<SelectOption>();
        ContactsTables.add(new SelectOption('5','5'));
        ContactsTables.add(new SelectOption('10','10'));
        ContactsTables.add(new SelectOption('20','20'));
        ContactsTables.add(new SelectOption('50','50'));
        ContactsTables.add(new SelectOption('100','100'));
    }
    public ApexPages.StandardSetController Setcon { 
        get { 
        if(Setcon == Null)
         { 
            Setcon = new ApexPages.StandardSetController(Database.getQueryLocator([Select Name,Accountid,Email,MobilePhone,LeadSource from Contact])); 
    
            setCon.setpagesize(size); 
            noOfRecords = setCon.getResultSize(); } 
            return Setcon; 
        }
        set;
    } 
 
 public PageReference refreshPageSize() {
         Setcon.setPageSize(size);
         return null;
    }
    
    Public List<WrapperContactWrapper> getContact() { 
        getSelectedContact();
        wrapperlist = new List <WrapperContactWrapper>(); 
        
        for(Contact cc : (List<contact>)Setcon.getRecords()) { 
            if( SelectedcontactMap .ContainsKey(cc.id)) { 
                wrapperlist.add (new WrapperContactWrapper(cc,true));
            } else { 
            wrapperlist.add(new WrapperContactWrapper(cc,false));
            }
        } 
        return wrapperlist;
    }
    
    public void getSelectedContact(){ 
        if(wrapperlist!=null) { 
            for(WrapperContactWrapper wr:wrapperlist) { 
                if(wr.bool == true) { 
                    SelectedcontactMap.put(wr.con.id,wr.con); 
                } else { 
                    SelectedcontactMap.remove(wr.con.id);      
                }      
            }
        }
    }
          
   public void clickMe() { 
        display = true; 
        getSelectedContact(); 
        selectedList = SelectedcontactMap.values();
        getContact(); 
}
    
    public integer pageNumber { 
        get { 
            return Setcon.getPageNumber();
        }
        set;
    }
}

 
This was selected as the best answer
badrul Hassanbadrul Hassan
Hi  Agent Comms 7,

Could you please mark it as best answer it you found it helpful!
Agent Comms 7Agent Comms 7
hi, badrul
thank you so much..
but if   i am selecting  5 records by clicking checkbox, and then when i am clicking on Processed button. its only showing me 1 record but i want to see all the checked record..
how i will do that... 
it was worked in my code which i have posted. when i added your code the dropdown is working,but the Processed  button function is not working.
what is the solution...?
badrul Hassanbadrul Hassan
Hi Agent, Please upload you code here. I will check it ?,
Agent Comms 7Agent Comms 7
vfpage:-
<apex:page controller="ContactsTable1" sidebar="false" showHeader="false">

    <apex:form id="myform">

   

        <apex:pageblock id="pbId" >

                <apex:pageBlockSection columns="1" >

                <apex:pageblock >  

            <!-- In our table, we are displaying the Contact records -->

         <apex:pageblockButtons location="Top">

     <apex:commandButton value="Processed" action="{!clickMe}" />

    </apex:pageblockButtons>      

          <apex:pageblocktable value="{!Contact}" var="cc" id="test"  >

                <apex:column headerValue="Choose Contact">

                <apex:inputCheckbox value="{!cc.bool}"/> </apex:column>

                <apex:column value="{!cc.con.Name}"/>

                <apex:column value="{!cc.con.Email}"/>

          </apex:pageblocktable>


                <apex:pageBlockButtons location="Bottom">

                <apex:commandButton value="First" action="{!Setcon.First}" disabled="{!NOT(Setcon.hasPrevious)}" reRender="myform" />

                    <apex:commandButton value="Previous" action="{!Setcon.Previous}" disabled="{!NOT(Setcon.hasPrevious)}" reRender="myform" />

                    <apex:commandButton value="Next" action="{!Setcon.Next}" disabled="{!NOT(Setcon.hasNext)}" reRender="myform" />

                    <apex:commandButton value="Last" action="{!Setcon.Last}" disabled="{!NOT(Setcon.hasNext)}" reRender="myform" />

                </apex:pageBlockButtons>
                
                <apex:actionFunction name="refreshPageSize" action="{!refreshPageSize}" status="fetchStatus" reRender="pbId"/>

                  <apex:selectList value="{!size}" multiselect="false" size="1" onchange="refreshPageSize();">

                    <apex:selectOptions value="{!ContactsTables}"/>

                </apex:selectList>

                </apex:pageblock>

                <apex:pageBlock >

                    <apex:outputPanel rendered="{!display}">
                        <apex:pageblocktable value="{!selectedList}" var="w" rows="1" columns="2" >

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

                        <apex:column value="{!w.Email}"/>

                    </apex:pageblocktable>

                    

               </apex:outputPanel>

      </apex:pageblock>

    </apex:pageBlockSection>

      </apex:pageblock>

         

    </apex:form>

</apex:page>

controller:-
//Controller
Public class ContactsTable1{
 
    //public String size { get; set; }
    public Integer size { get; set; }
    Public List<WrapperContactWrapper> wrapperlist;
    Public Integer noOfRecords{get; set;}
    Map <id,Contact> SelectedcontactMap = new Map <id,Contact>();
    public boolean display{get;set;}
    public list<Contact> selectedList {get;set;}
    public List<SelectOption> ContactsTables{get;set;}
 
    Public class WrapperContactWrapper {
        Public Contact con{get;set;}
        Public boolean bool{get;set;}
        public WrapperContactWrapper(Contact c,boolean bool) {
            this.con = c; 
            this.bool = bool;
        }
    }
    
    public ContactsTable1 (){
        size=10;

        ContactsTables= new List<SelectOption>();

        ContactsTables.add(new SelectOption('5','5'));

        ContactsTables.add(new SelectOption('10','10'));

        ContactsTables.add(new SelectOption('20','20'));

        ContactsTables.add(new SelectOption('50','50'));

        ContactsTables.add(new SelectOption('100','100'));

    }
 
    public ApexPages.StandardSetController Setcon {
        get { if(Setcon == Null) {
            Setcon = new ApexPages.StandardSetController(Database.getQueryLocator([Select Name,Accountid,Email,MobilePhone,LeadSource from Contact]));
     
            setCon.setpagesize(size);
            noOfRecords = setCon.getResultSize(); }
            return Setcon;
        }
        set;
    }
    public PageReference refreshPageSize() {

         Setcon.setPageSize(size);

         return null;

    }
  
    Public List<WrapperContactWrapper> getContact() {
        getSelectedContact();
        wrapperlist = new List <WrapperContactWrapper>();
         
        for(Contact cc : (List<contact>)Setcon.getRecords()) {
            if( SelectedcontactMap .ContainsKey(cc.id)) {
                wrapperlist.add (new WrapperContactWrapper(cc,true));
            } else {
            wrapperlist.add(new WrapperContactWrapper(cc,false));
            }
        }
        return wrapperlist;
    }
     
    public void getSelectedContact(){
        if(wrapperlist!=null) {
            for(WrapperContactWrapper wr:wrapperlist) {
                if(wr.bool == true) {
                    SelectedcontactMap.put(wr.con.id,wr.con);
                    
                } else {
                    SelectedcontactMap.remove(wr.con.id);  
                    System.debug('@@@123'+SelectedcontactMap);   
                }     
            }
       }
    }
   
    /*public void clickMe() {
        display = true; 
        getSelectedContact();
        selectedList = SelectedcontactMap.values();
    }*/
    
    public void clickMe() {
        display = true;
        getSelectedContact();
        selectedList = SelectedcontactMap.values();
        wrapperlist = null;
        SelectedcontactMap.clear();
        getContact();
}
     
    public integer pageNumber {
        get {
            return Setcon.getPageNumber();
        }
        set;
    }
}
 
badrul Hassanbadrul Hassan
Hi Agent,

Remove Row="1"
User-added image

please mark it as best answer it you found it helpful!
Agent Comms 7Agent Comms 7
Please check... this is my code
Agent Comms 7Agent Comms 7
thanks, badrul 
now it is working..
 
badrul Hassanbadrul Hassan
 Hi Agent,
please mark it as best answer it  because other use this code !!!

Thanks