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
Manoj ReddiManoj Reddi 

How can i get records for picklist Field Using Visualforce Page Code ?

Hi,

How can i get records for picklist  Field  Using Visualforce Page Code ?

User-added image
Jasper WallJasper Wall
public List<SelectOption> getStageItems()
{
Schema.DescribeFieldResult stageItems = Opportunity.Stagename.getDescribe();
List<Schema.PicklistEntry> stageValues = stageItems.getPicklistValues();
List<SelectOption> items=new List<SelectOption> ();
items.add(new SelectOption('','Please Select'));
for(Schema.PicklistEntry p:categroyValues)
{
items.add(new SelectOption(p.getValue(),p.getLabel()));
}
return items;
}

 
Manoj ReddiManoj Reddi
Hi Balayesu ,

Thanks for reply
 
Send me Visualforce code  ?
James LoghryJames Loghry
Hi Manoj,

If you're attempting to reference a standard or custom field it could be something as simple as using the apex:inputField tag in Visualforce.
 
<apex:inputField value="{!Opportunity.StageName}" />

or
 
<apex:inputField value="{!myCustomObjectInstance.My_Custom_Field__c}" />


More info on the apex:inputField tag can be found here: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputField.htm
Jasper WallJasper Wall
<label for="stagename" style="font-size: 100%;"> Stage<span class="required"> *</span>
                                                        <apex:selectList value="{!obj.StageItem}" 
                                                                         multiselect="false" size="1"  
                                                                         style=" width: 120%;">
                                                            <apex:selectOptions value="{!StageItems}"/>
                                                        </apex:selectList>
                                                    </label>

Thanks,
Balayesu