function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Storing the picklist values

To design a drop down list box (i.e) Picklist in visualforce is it necessary to create a custom object to store picklist values?


It can be done while creating select list ( in sorted way) or if this is sandard pick list we need to show on VF page then there is an option to make it sort on editing field setting 


custom Object- > field-> Edit


Give me Kudos if it was helpful and mark it as solution


I have a field having data type as string. I have to get the details available in that field and display it as a combo box in visualforce page.Is this possible?If so can you share some code to do it?


Yes it is possible with few custom code like,

1. query to get the values of all the records for the field X of the object (Naming the field with data type string as 'X')

2. Store it into a list

3.Make that list as your <apex:selectOptions> 'value'


By following this you would be able to get the field X's values from your salesforce instance, into a picklist




I have read this code some where so you can get some help from this


<apex:page controller="chooseColor">
        <apex:selectList id="chooseColor" value="{!string}" size="1">
            <apex:selectOption itemValue="red" itemLabel="Red"/>
            <apex:selectOption itemValue="white" itemLabel="White"/>
            <apex:selectOption itemValue="blue" itemLabel="Blue"/>
 /*** Controller ***/
public class chooseColor { String s = 'blue'; public String getString() { return s; } public void setString(String s) { this.s = s; } }