I have following code
VF Page:
< apex:page controller="DisplayBooks">
< apex:form >
< apex:selectList value="{!selectedVal}" size="1">
< apex:selectOptions value="{!openPresentationOptions}" />
< /apex:selectList>
< /apex:form>
< /apex:page>
Class:
public class DisplayBooks {
public String openPresentationOptions { get; set; }
public String selectedVal { get; set; }
public List<SelectOption> getopenPresentationOptions(){
List<selectOption> options = new List<selectOption>();
for(Books__c book : [SELECT Id,Name__c FROM Books__c]){
options.add(new SelectOption(book.Id,book.Name__c));
}
return options;
}
}