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
Manu@devManu@dev 

Difference between Itemvalue and Itemlabel

Hi all,

 

Please tell me the difference between Itemvalue and ItemLabel attributes.

 

In one code I have seen <apex:selectOption itemValue="Course" itemLabel="Course Name"/>

 

Please explain what purpose these both attributes are using in the above line. Request explanation in detail as I am brand new to Salesforce.

 

Regards,

Manu

 

Satish_SFDCSatish_SFDC

Hi,

ItemLabel is the value which is shown to the user in the dropdown (picklist). But ItemValue is the value which is sent to the server when user selects the label.

So your itemLabels can be text values and your itemValues can be codes. When user selects an option from the list, the corresponding itemValue will be sent to the server.

 

 

Regards,

Satish Kumar


Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.

souvik9086souvik9086

itemLabel - The label used to display this option to users.

 

itemValue - The value sent to the server if this option is selected by the user.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

Manu@devManu@dev
Hi Satish/souvik/Ambiga,

Many thanks for your replies. I have one more small doubt in this.

I just now written the following code.

<apex:pageBlockSectionItem >
<apex:selectList multiselect="false" size="1">
<apex:selectOption itemValue="BPO Sector"/>
<apex:selectOption itemLabel="IT" />
<apex:selectOption itemLabel="HR" />
</apex:selectList>
</apex:pageBlockSectionItem>

If ItemLabel is not specified still the name appears in picklist. Why?
If ItemValue is only specified the name appears and if I save the record now, will it save in database
souvik9086souvik9086

If you don't mention itemLabel then itemValue will be displayed by default and that will be passed to the server and save in the database I think.

 

If you mention itemLabel then it will be displayed but itemValue will be passed to server and saved.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks