+ Start a Discussion

Passing data from one vf page to another

Hi can anyone help.

i have 2 pages



the first page has a next button on which i call the second page

next button code:

PageReference newpage = new PageReference('/apex/secondpage');
              return newpage;  


 the second page has a previous button which calls back the first page.

previous button code:

PageReference newpage = new PageReference('/apex/firstpage');
              return newpage;  

 Now the problem i am facing is when i click on previous button.it again calls the page n i get the data in my drop down list 2 times instead of once.

like if my firstpage has a drop down list with dynamic values like a,b,c

when i click on previous i get a,b,c,a,b,c in drop down.

and i need to keep setRedirect false as i want default value of drop down to be the one(when i click on previous button),which the user had clicked while navigating from the first page to the second.Can some please help.


Please help



can you share your full class code here?


thanks for the reply.

its a very huge code.

N im sure when i post such huge code no one replies.

Did u get my problem?



then put the Function through which your dropdown get filling.


Actually i am calling the values from my webservice.

So when i click on the method...may be the webservice is called again and i get the  values 2 times


public List<SelectOption> getItems() {
            List<SelectOption> options2 = new List<SelectOption>();
            sqlArray18.ArrayOfstring a= new sqlArray18.ArrayOfstring();  
        a1.BasicHttpBinding_IService1 stub = new a1.BasicHttpBinding_IService1();   
      a  = stub.Getdatabasename();
     String[] returnArray = a.string_x;
for(String s: returnArray)
    System.Debug('*****************' + s);
    options2.add(new SelectOption(s,s));
    return options2;