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
pooja biswaspooja biswas 

bind sobjects to picklist

HI friends
I have a requirement where I need to bind sobjects to an picklist and show it in visual force page.
Can it be done using dynamic apex ?
pls let me know.

Best Answer chosen by pooja biswas
Srinivas SSrinivas S
Hi Pooja,

Please find the following solution which is tested -
Controller Class:
public class AllObjectsInPicklist {
    public List<SelectOption> getObjects() {
        List<SelectOption> options = new List<SelectOption>();
        for(Schema.SObjectType objTyp : Schema.getGlobalDescribe().Values()){
            options.add(new SelectOption(objTyp.getDescribe().getLabel(),objTyp.getDescribe().getName()));
        return options;
Visualforce Page:
<apex:page controller="AllObjectsInPicklist" tabStyle="Account">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title="Objects Selection" collapsible="false">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="object Type"/>
                    <apex:selectList size="1">
                        <apex:selectOptions value="{!objects}"/>
User-added image

- Please mark as solution if your problem is resolved.