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

How can I fill a picklist with existence objects?


I am new guy programing with apex, I was looking for a way to fill a picklist with objects data. For example:
I have a class called product with price and name, so we will suppose I added some products like juice, milk, etc.
Then I want to create a page with a picklist and fill it with the data I got (product class).
 Is this possible? how can I?
Could any body provide me some information?

Thank you very much,
Vinay JVinay J
Dear friend,

if product is a custom object, use product__c, otherwise if it's standard product object, then don't use __c

Public List<product__c> listProducts {get;set;}

listProducts = new List<product__c>([Select name from product__c]);
public List<SelectOption> listOfProductsForPage {get; private set;}

for(product__c product : listProducts) {
        listOfProductsForPage.add(new selectoption(,;

On page :-

<apex:selectlist multiselect="false" size="1" >
                <apex:selectoptions value="{!listOfProductsForPage}" >

Sree SalesforceSree Salesforce
public class product {

public string productlist{get;set;}

    public product(ApexPages.StandardController controller) {

   public list<selectoption> getproducts()
    list<selectoption> l1=new list<selectoption>();
    l1.add(new selectoption('','-none-'));
    l1.add(new selectoption('1','juice'));
    l1.add(new selectoption('2','milk')); 
    return l1; 

<apex:page standardController="account" showHeader="false" extensions="product">
<apex:form >
<apex:pageBlock >
   <apex:inputField value="{!}"/>
    <apex:selectList value="{!productlist}" label="products" size="1">
      <apex:selectOptions value="{!products}">

Mary Smith 22Mary Smith 22
Thanks for your question i got solution for my best juicer ( here 
hd sdhd sd
The faraway application tag is optionally available for new page (  It is used for inner utilization reporting facts.  We want to see which API programs are the most energetic, when they're active and so on.