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
sharath kanukuntla 7sharath kanukuntla 7 

if i click on any Account in picklist-1 corrosponded child(contact) should display on picklist-2 using wrapperclass..can anyone help me in doing this scenario..throough wrapper class in mandatory not in other ways

error:Error: AccountWithAssociatedContact_class Compile Error: Initial expression is of incorrect type, expected: System.SelectOption at line 62 column 57
vf============
<apex:page controller="AccountWithAssociatedContact_class">
 <apex:form >
  <apex:pageBlock title="Account with related Contacts">
   <apex:pageBlockButtons >
    <apex:commandButton value="show relted contacts" action="{!displaycontacts}"/>
   </apex:pageBlockButtons>
   <apex:pageBlockSection >
    <apex:selectList size="1" label="Accounts">
     <apex:selectOptions value="{!Accounts}"/> 
       </apex:selectList><br/>
       
      <apex:selectList size="1" label="related Contacts">
       <apex:selectOptions value="{!contacts}"/>
      </apex:selectList>
   </apex:pageBlockSection>
  </apex:pageBlock>
 </apex:form>
</apex:page>

controller=====
public with sharing class AccountWithAssociatedContact_class {
    public string  acc1{set;get;}
    public string con1{set;get;}
    public list<SelectOption> contacts { get; set; }
    public list<SelectOption> Accounts { get; set; }
    //crete a wrapperclass i.e
    public list<WrapperAccountContact> Wrapper{set;get;}
    //create Map to store id(Account) and values(contacts)
    public Map<list<Account>,list<Account>> maps{set;get;}
    public class WrapperAccountContact{
    public list<Account> Acc{set;get;}
    public list<Account> con{set;get;}
   
    }
    
    public AccountWithAssociatedContact_class(){
    Accounts =new list<SelectOption>();
    contacts=new list<SelectOption>();
    Wrapper = new list<WrapperAccountContact>();
    maps=new Map<list<Account>,list<Account>>();
    list<Account> acc1=[SELECT id,name FROM Account];
      WrapperAccountContact w1= new WrapperAccountContact();
      w1.Acc=Acc1;
      Wrapper.add(w1);
            //string query1='SELECT id,name FROM Account';
            //acc1=database.query(query1);
    
    
    list<Account> con1=[SELECT id,name,(SELECT id,name FROM Contacts) FROm Account];
    WrapperAccountContact w2= new WrapperAccountContact();
    w2.con=con1;   
    wrapper.add(w2);
          //string query2='SELECT id,name,(SELECT id,name FROM Contacts) FROm Account';
         //con1=database.query(query2);
    
    /*for(Account a:acc1){
     WrapperAccountContact w1= new WrapperAccountContact();
      w1.Acc=Acc1;
      Wrapper.add(w1);
    }*/
    
   /*for(Account a:acc1){
    WrapperAccountContact w2= new WrapperAccountContact();
    w2.con=con1;   
    wrapper.add(w2);
    }*/
    
     selectoption op = new selectOption('--None--','--None--');
       Accounts.add(op);
       contacts.add(op);
       
      
    for(WrapperAccountContact w:wrapper){
         maps.put(w.acc,w.con);
        system.debug('value in map are========='+maps);
    }
      Set<List<Account>> keys=maps.keySet();
       system.debug('id in keysare========='+keys);
       
       
                        for(List<Account> s:keys){
        62--line>    list<selectOption> lst = new list<selectOption>{s,s};
          
        }       
    }
    
   
    
    public PageReference displaycontacts() {
        return null;
    }
    
    

  
}