You need to sign in to do that
Don't have an account?

Select Options
Hi my class is below
public class SendEmailToCandidates {
public String positionSelected{get; set;}
//get Positions
public List<SelectOption> getPositionList()
{
List<Selectoption> optns=new List<Selectoption>();
List<Position__c> position=[select name,id from Position__c];
for(Position__c pos:position)
{
optns.add(new Selectoption(pos.name,pos.name));
}
System.debug(position);
return optns;
}
//constructor
public SendEmailToCandidates()
{
applicantsList=new List<Job_Application__c>();
positionList=new Position__c();
}
}
i'm populating positions
but i' m not able to get the positons in the drop down
my page is
<apex:page controller="SendEmailToCandidates">
<apex:form >
<apex:selectList value="{!positionSelected}" >
<apex:selectOptions value="{!positionList}" >
</apex:selectOptions>
</apex:selectList>
</apex:form>
<apex:page>
error is:
Invalid selectOptions found. Use SelectOption type in Apex.
Help me
The answer is in the error.
Invalid selectOptions found. Use SelectOption type in Apex.
In the class you have SelectOption . In VFP, SelectOptions
public List<SelectOption> getPositionList()
{
List<Selectoption> optns=new List<Selectoption>();
my page is
<apex:page controller="SendEmailToCandidates">
<apex:form >
<apex:selectList value="{!positionSelected}" >
<apex:selectOptions value="{!positionList}" >
</apex:selectOptions>
</apex:selectList>
</apex:form>
<apex:page>
Its the syntax for getting list of options in the visual force page
https://ap1.salesforce.com/apexpages/apexcomponents.apexp
Try this -
Positions in drop down list -
What is this line? positionList=new Position__c();
Possibly rewrite your controller as:
public class SendEmailToCandidates {
public String positionSelected{get; set;}
public List<SelectOption> getPositionList()
{
List<SelectOption> optns = new List<SelectOption>();
for (Position__c pos : [select name, id from Position__c]) optns.add(new SelectOption(pos.name,pos.name));
return optns;
}
}
Best, Steve.