You need to sign in to do that
Don't have an account?
sharath kanukuntla 7
Scenario:i have two picklist-1 for list of Account, if i click on any Account corrosponded child(contact) should display on picklist-2
in my code iam getting itemlebels in picklist instead of Accont..but it is showing(size) number of Accounts
vf========
<apex:page controller="AccountWithAssociatedContacts_class">
<apex:form >
<b>No of Accounts</b>{!k}
<apex:pageBlock >
<apex:pageBlockSection >
<apex:selectList size="1" multiselect="fasle" value="{!listofAccounts}">
<apex:selectOptions value="{!options}"/>
</apex:selectList>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="displayContacts" action="{!displayContacts}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!cons}" var="c">
<apex:column headerValue="Name" value="{!c.Name}"/>
<apex:column headerValue="Email" value="{!c.email}"/>
<apex:column headerValue="phone" value="{!c.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
class=-==============
public class AccountWithAssociatedContacts_class {
public PageReference displayContacts() {
cons=[SELECT id,name,email,phone FROM Contact WHERE Accountid=:listofAccounts];
return null;
}
public String listofAccounts { get; set; }
public integer k{set;get;}
public list<Account> Display{set;get;}
public list<contact> cons { set; get; }
public list<SelectOption> options{ set; get; }
public AccountWithAssociatedContacts_class(){
options=new list<SelectOption>();
options.add(new selectOption('','---------------None---------------'));
display=[SELECT id,name,phone FROM Account];
system.debug('Accounts are===='+display);
if(!display.isEmpty()){
for(Account a1:display){
options.add(new selectOption('a1.id','a1.name'));
k=display.size();
}
}
}
}
thanks in advance
vf========
<apex:page controller="AccountWithAssociatedContacts_class">
<apex:form >
<b>No of Accounts</b>{!k}
<apex:pageBlock >
<apex:pageBlockSection >
<apex:selectList size="1" multiselect="fasle" value="{!listofAccounts}">
<apex:selectOptions value="{!options}"/>
</apex:selectList>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="displayContacts" action="{!displayContacts}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!cons}" var="c">
<apex:column headerValue="Name" value="{!c.Name}"/>
<apex:column headerValue="Email" value="{!c.email}"/>
<apex:column headerValue="phone" value="{!c.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
class=-==============
public class AccountWithAssociatedContacts_class {
public PageReference displayContacts() {
cons=[SELECT id,name,email,phone FROM Contact WHERE Accountid=:listofAccounts];
return null;
}
public String listofAccounts { get; set; }
public integer k{set;get;}
public list<Account> Display{set;get;}
public list<contact> cons { set; get; }
public list<SelectOption> options{ set; get; }
public AccountWithAssociatedContacts_class(){
options=new list<SelectOption>();
options.add(new selectOption('','---------------None---------------'));
display=[SELECT id,name,phone FROM Account];
system.debug('Accounts are===='+display);
if(!display.isEmpty()){
for(Account a1:display){
options.add(new selectOption('a1.id','a1.name'));
k=display.size();
}
}
}
}
thanks in advance