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
Geetha BGeetha B 

I am not getting picklist values from controller can anyone help me.

here is the vf page and controller

<apex:page controller="getListOptions">
  <apex:form >
 
      select <apex:selectList size="1" title="Country">
          <apex:selectOptions value="{!lstoptions}"></apex:selectOptions>
      </apex:selectList>
     
  </apex:form>
</apex:page>
___________________________________________________
public class getListOptions
{
  
    public list<selectoption> lstoptions{get; set;}
//    public list<selectoption> lstoptions{get; set;}
    public list<selectoption> getlstoptions()
    {
   
      list<selectoption> options  = new list<selectoption>();
      options.add(new selectoption('','select country'));
      options.add(new selectoption('India','IND'));
      options.add(new selectoption('US','US'));
      options.add(new selectoption('Canada','CA'));
      return options;
      
     }

}
Ramesh KallooriRamesh Kalloori
public class getListOptions
{
  
  //  public list<selectoption> lstoptions{get; set;}
//    public list<selectoption> lstoptions{get; set;}
    public list<selectoption> getlstoptions()
    {
   
      list<selectoption> options  = new list<selectoption>();
      options.add(new selectoption('','select country'));
      options.add(new selectoption('India','IND'));
      options.add(new selectoption('US','US'));
      options.add(new selectoption('Canada','CA'));
      return options;
      
     }

}
try the above it will work.

thanks,
Ramesh
praveen murugesanpraveen murugesan
HI Geetha,

try this,
<apex:page controller="PickListController">
  <apex:form >
 
                    <apex:SelectList id="List" value="{!selectedcountry}" size="1">  <!-- selected value will stored in this variable -->
                        <apex:selectOptions value="{!lstoptions}"/> 
                    </apex:SelectList>
                    
       <!--             
      select <apex:selectList size="1" title="Country">
          <apex:selectOptions value="{!lstoptions}"></apex:selectOptions>
      </apex:selectList>  -->
     
  </apex:form>
</apex:page>
public with sharing class PickListController {

    public String selectedcountry { get; set; }

    public list<selectoption>  lstoptions { get; set; }
    
    public PickListController()
    {
      list<selectoption> options  = new list<selectoption>();
      options.add(new selectoption('','select country'));
      options.add(new selectoption('India','IND'));
      options.add(new selectoption('US','US'));
      options.add(new selectoption('Canada','CA'));
      lstoptions = options;
    
    }
}

Thanks