Display child records when selecting parent record from dropdown list?
By using Action Support function we can achieve this scenario
public class ActionSupportController
{
public list lstoption {get; set;}
public list lstaccount {get; set;}
Public List lstContacts {get; set;}
Public string selectedAccount {get;set;}
public ActionSupportController()
{
lstoption=new list();
lstaccount= [select id,name from account order by name];
lstoption.add(new selectoption('','--None--'));
for(account acc: lstaccount)
{
lstoption.add(new selectoption(acc.id,acc.Name));
}
}
Public PageReference LoadContacts()
{
lstContacts = [select id, firstname, lastname,phone,LeadSource,Department,Status__c,Email from contact where accountid =: selectedAccount];
return null;
}
}