Play Games

Search This Blog

Tuesday, October 18, 2016

How to display dropdown values in visualforce page

Apex Class:
public class DropDownController {
    public String selectedVal {get;set;}
    public List<SelectOption> getPicklistOptions() {
        List<SelectOption> options = new List<Selectoption>();
        options.add(new selectOption('One', 'One'));
        options.add(new selectOption('Two', 'Two'));
        options.add(new selectOption('Three', 'Three'));
        options.add(new selectOption('Four', 'Four'));
        return options;
    }
}
Visualforce Page:
<apex:page controller="DropDownController">
    <apex:form >
        <b>Numbers DropDown </b>:<apex:selectList value="{!selectedVal}" size="1">
        <apex:selectOptions value="{!PicklistOptions}"/>
        </apex:selectList>
    </apex:form>
</apex:page>
Output: 

No comments:

Post a Comment