+ Start a Discussion

I want to display Previous and Next buttons in object record display page

Hi all,
I generate the code for displaying the records of object choosen in picklist field (Lead and Contact)
Actually i want to add Previous and Next buttons after dipalying the records..
Example if have 50 records first it will displayed only 10 records for next records we should have Next Or previous buttons...........
Here is my code...
Apex class :
public class objectcontroller
    public List<selectOption> objects{get; set;}
    public string selected{get; set;}
    public List<contact> obj1{get; set;}
    public list<lead> obj2{get; set;}
    public boolean obj1Status{get; set;}
    public boolean obj2Status{get; set;}
    public list<wrapcontact> wrapcon{get;set;}
    public list<wrapLead> wrapLd{get;set;}
    public objectcontroller()
        objects= new List<selectOption>();
        objects.add(new selectOption('contact','contact'));
        objects.add(new selectOption('lead','lead'));
        wrapcon = new List<wrapcontact>();
        wrapLd = new list<wrapLead>();
    public pageReference getRecordofObject()
            for(contact c :[select id,lastname,Email from contact limit 100]){
            wrapcon.add(new wrapcontact(c));
            for(lead l:[select name,company,Status from lead limit 100]){
                wrapLd.add(new wrapLead(l));
        return null;
    public class wrapcontact {
        public contact con {get; set;}
        public Boolean selected {get; set;}
        public wrapcontact(contact a) {
            con = a;
            selected = false;
    public class wraplead{
        public lead Ld {get; set;}
        public Boolean selected {get; set;}
        public wraplead(lead a) {
            Ld = a;
            selected = false;
Visulaforce page :
<apex:page controller="objectcontroller" showHeader="false">
    <apex:form >
        <apex:pageBlock title="Select a object">
            <apex:selectList value="{!selected}" size="1">
                <apex:selectOptions value="{!objects}"/>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!getRecordofObject}" value="Show Records" rerender="cb"/>
        <apex:outputPanel >
            <apex:pageBlock id="cb">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!wrapcon}" var="ob1" rendered="{!obj1Status}">
                        <apex:column >
                            <apex:inputCheckbox value="{!ob1.selected}" id="inputId"/>
                        <apex:column value="{!ob1.con.id}"/>
                        <apex:column value="{!ob1.con.lastname}"/>
                        <apex:column value="{!ob1.con.Email}"/>
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!wrapLd}" var="ob2" rendered="{!obj2Status}">
                        <apex:column >
                            <apex:inputCheckbox value="{!ob2.selected}" id="inputId"/>
                        <apex:column value="{!ob2.Ld.id}"/>
                        <apex:column value="{!ob2.Ld.company}"/>
                        <apex:column value="{!ob2.Ld.status}"/>

Thanks in advance.......
Best Answer chosen by nihar
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi Nihar,
Please refer below links which might help you in this.

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards