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
Deepak agarwal 9Deepak agarwal 9 

Error: Constructor not defined: [System.SelectOption].<Constructor>(Integer, Integer)

public class my6 {
string Calender='cale';
public List<SelectOption> getdates() {
 List<SelectOption> options = new List<SelectOption>();
 for(integer i=1890;i<2000;i++){
 options.add(new SelectOption(+i,+i));
       }
   return options;
        }
       public string getCalender(){
        return Calender;
        }
public void setCalender(string Calender){
this.Calender=Calender;
}

}

 
Best Answer chosen by Deepak agarwal 9
karthikeyan perumalkarthikeyan perumal
Hello

use below updated code, it will works fine. 
 
public class my6 {
string Calender='cale';
public List<SelectOption> getdates() {
 List<SelectOption> options = new List<SelectOption>();
 options.add(new SelectOption('','-- Select --'));
 for(integer i=1890;i<2000;i++){
 options.add(new SelectOption(string.Valueof(+i),string.Valueof(+i)));
       }
   return options;
 }
       public string getCalender(){
        return Calender;
        }
public void setCalender(string Calender){
this.Calender=Calender;
}

}
Mark best ANSWER if its works for you.. 

Thanks
karthik

 

All Answers

karthikeyan perumalkarthikeyan perumal
Hello

use below updated code, it will works fine. 
 
public class my6 {
string Calender='cale';
public List<SelectOption> getdates() {
 List<SelectOption> options = new List<SelectOption>();
 options.add(new SelectOption('','-- Select --'));
 for(integer i=1890;i<2000;i++){
 options.add(new SelectOption(string.Valueof(+i),string.Valueof(+i)));
       }
   return options;
 }
       public string getCalender(){
        return Calender;
        }
public void setCalender(string Calender){
this.Calender=Calender;
}

}
Mark best ANSWER if its works for you.. 

Thanks
karthik

 
This was selected as the best answer
Deepak agarwal 9Deepak agarwal 9
Thanks a lot karthik it helped..
One more thing it should display as a list..All values sholud not be displayed at a time.
 
karthikeyan perumalkarthikeyan perumal
Hello, 

add this line into declaration part so that values are in list. 
 
public List<SelectOption> options {get;set;}
http://​http://sfdcsrini.blogspot.com/2014/07/how-to-use-apexselectoptions-and.html

also have a look on this link.

Hope this will help you. 

Thanks
karthik