You need to sign in to do that
Don't have an account?
sudhirn@merunetworks.com
How to make default value in select list
Hi,
In visual force page we are displaying picklist with Yes or No Option we need to make No as a default view on visual force page. Please suggest how to make the change on this code
In visual force page we are displaying picklist with Yes or No Option we need to make No as a default view on visual force page. Please suggest how to make the change on this code
<apex:outputLabel value=" Renewal Opportunity" for="RenOpp"/> <apex:selectList value="{!RenewalOpportunity}" multiselect="false" size="1"> <apex:selectOptions value="{!RenewalOpp}" /> </apex:selectList>
Thanks
Sudhir
When you use custom picklist you should not use the standard picklist. Just remove the below line from your code.
Replace this line
<apex:selectOptions value="{!RenewalOpp}" />
with below 2 lines
<apex:selectOption itemValue="No" itemLabel="No"/>
<apex:selectOption itemValue="Yes" itemLabel="Yes"/>
Thanks
Kumar
All Answers
Are you displaying a custom picklist built in controller or a standard picklist field? If you are displaying a custom picklist then you can change the display order in VFP.
Thanks
Kumar
Try this and see if No appears as default value in VFP.
<apex:outputLabel value=" Renewal Opportunity" for="RenOpp"/>
<apex:selectList value="{!RenewalOpportunity}" multiselect="false" size="1">
<apex:selectOption itemValue="No" itemLabel="No"/>
<apex:selectOption itemValue="Yes" itemLabel="Yes"/>
</apex:selectList>
PS: Please mark this as Best Anwer if it solves your problem.
Hi Kumar,
I am using standard picklist from the object if i use your code it is duplicating the value displaying multiple times.
Thanks
Sudhir
When you use custom picklist you should not use the standard picklist. Just remove the below line from your code.
Replace this line
<apex:selectOptions value="{!RenewalOpp}" />
with below 2 lines
<apex:selectOption itemValue="No" itemLabel="No"/>
<apex:selectOption itemValue="Yes" itemLabel="Yes"/>
Thanks
Kumar
No issues. As you are asssigning it to the right variable RenewalOpportunity in Selectlist component.
Thanks
Kumar
PS: Please mark this as Best Anwer if it solves your problem.
<apex:selectOption itemValue="" itemLabel="---None---" ></apex:selectOption>
<apex:selectOption itemValue="Yes" itemLabel="Yes"></apex:selectOption>
<apex:selectOption itemValue="No" itemLabel="No"></apex:selectOption>
I need to display None as default. Any pointers on this?
Thanks ..