+ Start a Discussion




In my visualforce page displayed records with pagination and  "edit" command link when i click on edit button

it will go to standard record edit mode when i cancel/save it will back to current page number but i have back to first page number.how to pass page number in pagereference?


Can any one help me?


Thank you 

Mudasir WaniMudasir Wani

Hi Varun,


You can use a controller variable to store the page number.

If you are using the action function you can update the variable by passing the value in param.

<apex:actionFunction action="{!methodOne}" name="methodOneInJavascript" rerender="showstate">
        <apex:param name="firstParam" assignTo="{!state}" value="" />

state will be name of your controller variable.


or simply you can store a value in hidden field and extract that value in your controller using


make sure you have the hidden field inside the same form tags.



Hi Mudasir,


Thanks for your reply.  Am passing id like


public void editrecord()


string bookingid= ApexPages.currentPage().getParameters().get('bookingid');
string aaaa=ApexPages.currentPage().getParameters().get('id');


PageReference page;

Page = new PageReference('/'+bookingid+'/e?retURL=/apex/bookingstatus?id='+aaaa);
return Page;



here bookingid is current edit recordid  but it return to first page number but not previous page number


my url like





Can u help? where am mistake?

Mudasir WaniMudasir Wani


Hi Varun,


Use the following code.


PageReference page = new PageReference('/'+bookingid+'/e?retURL=/apex/bookingstatus?id='+aaaa);


return page;