Activity Forums Salesforce® Discussions what is list used for in salesforce?

  • Mohit

    January 6, 2017 at 3:09 pm

    Hi Sushant,

    The List<SelectOption> is used to show the dynamic drop-down value on the visualforce page.

    For Eg:-

    Apex Controller:-

    public class sampleCon {

    String[] countries = new String[]{};

    public PageReference test() {
    return null;

    public List<SelectOption> getItems() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('US','US'));
    options.add(new SelectOption('CANADA','Canada'));
    options.add(new SelectOption('MEXICO','Mexico'));
    return options;

    public String[] getCountries() {
    return countries;

    public void setCountries(String[] countries) {
    this.countries = countries;


    Visualforce Page:-

    <apex:page controller="sampleCon">
    <apex:selectCheckboxes value="{!countries}">
    <apex:selectOptions value="{!items}"/>
    <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
    <apex:outputPanel id="out">
    <apex:actionstatus id="status" startText="testing...">
    <apex:facet name="stop">
    <p>You have selected:</p>
    <apex:dataList value="{!countries}" var="c">{!c}</apex:dataList>

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos