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
himanshu huske 7himanshu huske 7 

Constructor not defined: [System.SelectOption].<Constructor>(Id, String, String)

<apex:page controller="CustomerAmtTransfer">
    <apex:form >
    <apex:outputText>to</apex:outputText>>
    <apex:selectList size="1" value="{!Name1}" > 
        <apex:selectOptions value="{!name1fields}"/>  
    </apex:selectList><br/>
    <apex:outputText>from</apex:outputText>>
    <apex:selectList size="1" value="{!Name2}" > 
        <apex:selectOptions value="{!name2fields}"/>  
    </apex:selectList>
       </apex:form>
</apex:page>


public class CustomerAmtTransfer {

    public String Name1 { get; set; }
        public String Name2 { get; set; }


    public String getName1fields() {
    List<Selectoption> listName1 = new List<selectoption>();
    listName1.add(new selectOption('', '- None -'));
    for(Customer__c cs : [Select First_Name__c, Last_Name__c from Customer__c]){
     listName1.add(new selectoption(cs.id,cs.First_Name__c,cs.Last_Name__c));
     }
        return listName1;
    }
    public String getName2fields() {
    List<Selectoption> listName2 = new List<selectoption>();
    listName1.add(new selectOption('', '- None -'));
    for(Customer__c cs : [Select First_Name__c, Last_Name__c from Customer__c]){
     listName2.add(new selectoption(cs.id,cs.First_Name__c,cs.Last_Name__c));
     }
        return listName2;
    }
}
 
Khan AnasKhan Anas (Salesforce Developers) 
Hi Himanshu,

Greetings to you!

The SelectOption constructors signature is public SelectOption(String value, String label)

You are using 3 parameters instead of two. Please try below code, I have changed a few things in your code:
 
public class CustomerAmtTransfer {

    public String Name1 { get; set; }
    public String Name2 { get; set; }


    public List<Selectoption> getName1fields() {
    List<Selectoption> listName1 = new List<selectoption>();
    listName1.add(new selectOption('', '- None -'));
    for(Customer__c cs : [Select Id, First_Name__c, Last_Name__c from Customer__c]){
     listName1.add(new selectoption(cs.id,cs.First_Name__c));
     }
        return listName1;
    }
    public List<Selectoption> getName2fields() {
    List<Selectoption> listName2 = new List<selectoption>();
    listName2.add(new selectOption('', '- None -'));
    for(Customer__c cs : [Select Id, First_Name__c, Last_Name__c from Customer__c]){
     listName2.add(new selectoption(cs.id,cs.Last_Name__c));
     }
        return listName2;
    }
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas