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
Gaurav Agnihotri 11Gaurav Agnihotri 11 

Display the value for apex:selectlist opions

I am displaying a selection of options on the VF page :
<apex:column headervalue="VP Best/Likely/Worse">
                    <apex:outputpanel id="VP1" rendered="{!VP_View}">
                        <apex:outputtext value="{!oe.VP_best_Likely_Worst}"/>
                        <apex:selectlist id="Best2" value="{!oe.VP_best_Likely_Worst}" size="1" required="true">
                            <apex:selectoptions value="{!SelectBestLikelyWorse}" />
                        </apex:selectlist>
                    </apex:outputpanel>
                </apex:column>

Here is the controller:
public List<SelectOption> getSelectBestLikelyWorse()
	{
		List<SelectOption> options = new List<SelectOption> ();

		Schema.DescribeFieldResult fieldResult = Opportunity.Best_Likely_Worst__c.getDescribe();
		List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
		options.add(new SelectOption('---Select---', '---Select---'));

		for (Schema.PicklistEntry f : ple)
		{
			options.add(new SelectOption(f.getLabel(), f.getValue()));
		}
		return options;
	}

However, I am unable to display the value on the field. 
Deepali KulshresthaDeepali Kulshrestha
Hi Gaurav,

Apex:selectList is used to display list options that allow the user to select one or more values at a time.
Please refer to the following links as they may help you out with the query of yours:

https://developer.salesforce.com/forums/?id=906F0000000g28uIAA
https://salesforce.stackexchange.com/questions/131303/apexselectlist-value-how-to-set-it-initially
https://www.salesforcetutorial.com/apex-selectlist/
http://burnignorance.com/salesforce-tips/salesforce-custom-picklist-in-visualforce-page/
https://webkul.com/blog/how-to-create-dynamic-drop-down-in-visualforce-page/

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha