Skip to main content
2 of 2
improved
highfive
  • 6.3k
  • 3
  • 32
  • 58

You have to populate a List<SelectOption> to bind with the UI. Also have a variable to grab which have been selected from the select options. In your controller have below codes

public String selectedVal{get;set;}  // This will hold the selected value, the id in here

public List<SelectOption> getopenPresentationOptions(){
        List<SelectOption> optns = new List<Selectoption>();
        // before getting here you must populate your queryResult list with required fields
        for(Your_Object obj : queryResult){
           optns.add(new selectOption(obj.Id, obj.Name));
        }            
        
        return optns;
}

VF Page:

<apex:selectList value="{!selectedVal}" size="1"> 
    <apex:selectOptions value="{!openPresentationOptions}" /> 
</apex:selectList>

UPDATE : added code so that selectoptions list will be populated with a query result

highfive
  • 6.3k
  • 3
  • 32
  • 58