Type 1:Usage of picklist in vf & Apex

Picklist fields contain a list of one or more items from which a user chooses a single item. They display as drop-down lists in the Salesforce user interface. One of the items can be configured as the default item.For more Details http://www.salesforce.com/us/developer/docs/api/Content/field_types.htm

Example:Displaying the picklist in Visulaforce page.

<apex:page controller=”vfpage1″ sidebar=”false” showHeader=”false”>
<apex:form >
<apex:selectList value=”{!myVal}” multiselect=”true”>
<apex:selectOptions value=”{!myOptions}”/>
<apex:actionSupport event=”onchange” reRender=”one”/>
<apex:outputLabel id=”one”> <b>The selected value is : {!myVal} <b></apex:outputlabel>
public class vfpage1 {
public String myVal { get; set; }
public List<selectoption> getMyOptions() {
List< selectOption> ls= new list<selectOption>();
selectOption s0=new selectOption(‘Null’,’-Null-‘);
selectOption s1=new selectOption(‘1′,’One’);
selectOption s2=new selectOption(‘2′,’Two’);
selectOption s3=new selectOption(‘3′,’Three’);
return ls;



One thought on “Type 1:Usage of picklist in vf & Apex

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s