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
Rajesh SFDCRajesh SFDC 

how to solve this error pagination in visualforce page?

here my requirments i want to display all reocrds in visualforce previous i was used offset but offset it will disply 2000 records, so now i am using standardsetconroller method
i wanna to cal the two methods will display records in pages, i am getting an error in visualforce error:rror is in expression '{!IF((pageNumber * size)>noOfRecords, noOfRecords,(pageNumber * size))}' in component <apex:outputText> in page transactionsearch
visulaforce page
=================
<apex:commandButton status="fetchStatus" reRender="pb" value="|<Frist" action="{!first}" disabled="{!!hasPrevious}" title="First Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Previous" action="{!previous}" disabled="{!!hasPrevious}" title="Previous Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Next" action="{!next}" disabled="{!!hasNext}" title="Next Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Last>|" action="{!last}" disabled="{!!hasNext}" title="Last Page"/>
                <apex:outputText >{!(pageNumber * size)+1-size}-{!IF((pageNumber * size)>noOfRecords, noOfRecords,(pageNumber * size))} of {!noOfRecords}</apex:outputText>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/>
              
                    <apex:actionStatus id="fetchStatus" startText="Please Wait..." stopText=""/>
           ==========================================controller==================================================================
Public class clsTransactionSearch
   {
        Public Integer noOfRecords{get; set;}
         Public Integer size{get;set;}
        //end of declation pagination//

  public ApexPages.StandardSetController setCon
     {
        get{
            if(setCon == null)
            {
               system.debug('start here$$$$$$$$$$$$$$$$$$$$');
                size = 10;
                  }
            return setCon;
        }set;
    }
     public pageReference refresh()
     {
        setCon = null;
      
        setCon.setPageNumber(1);
        return null;
    }
    public Boolean hasNext
    {
        get {
            return setCon.getHasNext();
        }
        set;
    }
    public Boolean hasPrevious
    {
        get {
            return setCon.getHasPrevious();
        }
        set;
    }
 
    public Integer pageNumber
    {
        get {
            return setCon.getPageNumber();
        }
        set;
    }
    public void Next()
    {
            setCon.Next();
            system.debug('next method');
             if(SearchText ==''|| SearchText=='null' )
               {
                     BindGridOnLoad();
               }
               else if(SearchText !='')
                {
                  
                   BindGrid();
         
                 }
        }       
   
   

      public List<Transaction__c> getRecords()
      {
      return (List<Transaction__c>)database.query(queryString+' LIMIT '+queryLimit+' OFFSET '+offset);
     
      }
   
    
   
    public void Previous()
    {
         setCon.previous();   
          
        if(SearchText ==''|| SearchText =='null' )
        {
        BindGridOnLoad();
      
        }
        else if(SearchText !='')
        {
        BindGrid();
        }
    }
   

   
   public void first()
    {
         setCon.first();
        if(SearchText ==''|| SearchText =='null' )
        {
        BindGridOnLoad();
      
        }
        else if(SearchText !='')
        {
        BindGrid();
        }
    }
   
    
   
    public void last()
    {
      
       setCon.last();
       if(SearchText ==''|| SearchText =='null' )
        {
        BindGridOnLoad();
      
        }
        else if(SearchText !='')
        {
        BindGrid();
        }
    }
public void BindGrid()
    { 
          SearchQuery = SearchQuery + ' and ((t.Transaction_Headline__c like \'%' + SearchText + '%\') or (t.Buyer_Investors__c like \'%' + SearchText + '%\') or  (t.Target_Company__c like \'%' + SearchText + '%\')  or (t.Target__r.Name like \'%' + SearchText + '%\') ) and  t.Type2__c LIKE :finn t.Target_Sector2__c LIKE :fsbo';
            List<Transaction__c> que = Database.query(SearchQuery);
            // listSize = que.size();
           //  system.debug('_______llllllllll__________'+listSize +offset+queryLimit);
                setCon = new ApexPages.StandardSetController(que);
                system.debug('**********searchquery*********'+setcon);
                setCon.setPageSize(size);
               
                noOfRecords = setCon.getResultSize();
                  
}

public void BindGridOnLoad()
      {
          res+='and ( t.Type2__c LIKE :finn) and t.Target_Sector2__c = :fsbo ORDER BY t.Announce_Date__c Desc';
              
               
               
                //aggregateResult res=[Select COUNT(t.Id) cnt  from Transaction__c t where t.Id in : transId];
               //system.debug('count$______________$'+res ); 
              //listSize = Integer.valueOf(res.get('cnt'));
             //system.debug('count$______________$'+listSize ); 
          
               lstQuery = null;
              // lstQuery  = Database.query(res);
             
                setCon = new ApexPages.StandardSetController(Database.query(res));
                system.debug('**********setcon'+setCon);
                setCon.setPageSize(size);
                noOfRecords = setCon.getResultSize();

}
sachin_dreamoncloudsachin_dreamoncloud
You Cannot use If statement for returning value, the result should be boolean.

Use separate output text component and render it based on condition for different values.