Difference between apex:selectOption and apex:selectOptions in Salesforce?

Difference between apex:selectOption and apex:selectOptions in Salesforce?


apex:selectOption:
If we are sure about the values, we can make use of apex:selectOption.

Sample Code:

<apex:selectList >
     <apex:selectOption itemValue=”Apple” itemLabel=”Apple”/>     
     <apex:selectOption itemValue=”Orange” itemLabel=”Orange/>
     <apex:selectOption itemValue=”Banana” itemLabel=”Banana“/>
</apex:selectList>

apex:selectOptions:
If we are unsure about the values, we can make use of apex:selectOptions and we can fetch the values from our controller.

Sample Code:
<apex:selectOptions value={!ListofValues}/>

Cheers!!!

Leave a Reply