+ Start a Discussion
pramod sharma 15pramod sharma 15 

how to bind the picklist value selected from dynamic picklist


Question: How to bind the value selected from dynamic picklist onto controller. (I'm passing on session date 

In the below code snippet, user selects an session picklist value. Now I want to retrieve the complete session record based on selection. But when I try to assign the 'session' to an Sobject coaching__C, it is saying that its an invalid assignement of string to Sobject. How to use the selected picklist to bind/retrieve the selected session record?

Code Snippet:
public String Session {get;set;}
 
    
    public List<SelectOption> getsessionoptions() 
    {
         List<SelectOption> optionsz =  new List<SelectOption>();  
         list<coaching__C> archive = new list<coaching__c>();    
     archive = [select id,Coaching_Date__c,Coaching_Notes__c,Contact__c from Coaching__c where User__c = :UserInfo.getUserID() and Contact__c = :Subordinate]; 
                    
        for(coaching__c f:archive) {optionsz.add(new system.selectoption(f.id,string.valueof(f.Coaching_Date__c) ));}    
      
         return Optionsz; 
    }