I want to use the below code to display a custom picklist field's value in a visual force page.
Can you suggest how to link the below code with VF page?
public List<SelectOption> getTypeOptions(){
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('None','--None--'));
Schema.DescribeFieldResult fieldResult = National_Brand_Strategy__c.Strategy_Description__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.PicklistEntry p : ple)
options.add(new SelectOption(p.getValue(), p.getValue()));
return options;
}
Visulaforce code to bind this list value is as follows –
<apex:selectList >
<apex:selectOptions value="{!options}"/>
</apex:selectList>
Best Answer
the problem is that you have the code in a function. It has to be a property:
Your visual force code is fine, just change your apex code so that it's in a get{ }