You need to sign in to do that
Don't have an account?
Visualforce Error Invalid selectOptions found. Use SelectOption type in Apex.
i am trying to display list valus from an object using an listbox option am getting the following error here it the code .I missed some thing?I missed some thing in the code.
VF page
<apex:page controller="ABC">
<apex:selectList id="topq" value="{!top}" required="true" multiselect="false" title="Select " size="4"> <apex:selectOption value="{!pop}" />
</apex:selectList>
</apex:page>
controller:
value="{!top}" have it own get and seter.
List<CustomObject__c> pop;
public List<CustomObject__c> getpop() { if(pop== null) pop= [select customfield__c from CustomObject__c limit 100]; return pop; }
you are trying to set value selected from drop down to top hence you would need a public property in controller
public <object_type> top {get; set;}
also if pop is a list then use apex : selectoptions (plural)
check details in visualforce guide
I already tested that ,my geter,seter are public only.
Hi
You are binding the <apex:SelectOption> directly with sObject List
rather doing this do it like this way
public List<SelectOption> getpop()
{
pop = [select customfield__c from CustomObject__c limit 100];
if (pop.Size() >0)
{
for(CustomObject__c c:pop)
{
if (c.customfield__c != null)
options.add(new SelectOption(c.customfield__c,c.customfield__c));
}
}
return options;
}
I hope you got the feel of what i am trying to explain you
:)
I missed one more line of code
Please add this in function
List<SelectOption> options = new List<SelectOption>();