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
VinslikeuVinslikeu 

Invalid selectOptions found. Use SelectOption type in Apex.

Im tring to display a picklist from my custom object.

Facing this error: Invalid selectOptions found. Use SelectOption type in Apex.

 

////////////VF////////////////////
                <apex:selectList id="sta" value="{!SelectedState}">
                    <apex:selectOption value="{!StateList}" />
                </apex:selectList>

 

 

////////////////////////Controller////////////////////////

public with sharing class salesofficer {

    public list<SelectOption> StateList {
    get{
            list<SelectOption> st= new list<SelectOption>();
            Schema.DescribeFieldResult fieldResult = UV_Dealer__c.City__c.getDescribe();
            List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
            for( Schema.PicklistEntry f : ple)
            {
                st.add(new SelectOption(f.getLabel(), f.getValue()));
            }
            return st;
       }
     set; }

    public String SelectedState { get; set; }

 

 

Please help me in this code or suggest me any other easist way to do the same thing

Dhaval PanchalDhaval Panchal
hi,
replace

<apex:selectOption value="{!StateList}" />

with

<apex:selectOptions value="{!StateList}" />

use selectOptions instead of selectOption.
VinslikeuVinslikeu
It works but its showing all the options at a time. I want to show a
dropdown list.
how to do it?
Dhaval PanchalDhaval Panchal
use below
apex:selectList id="sta" value="{!SelectedState}" size="1" multiselect="false">