public class AccountContactC {
public string recid{get;set;}
public list<Account> Acclst{get;set;}
public List<Contact> contacts {get; set;}
public AccountContactC(){
Acclst = [select Id,Name from Account LIMIT 10];
contacts=null;
}
public void setupContacts() {
contacts=[select id, FirstName, LastName from Contact where AccountId=:recId];
}
}
I hope it helps you.
Kindly let me inform if it helps you and close your query by marking it as solved so that it can help others in future.
public class account_contact_controller {
public String Val{get;set;}
public List<SelectOption> opt {get;set;}
public list<Account> accList {get;set;}
public list<Account> acc_final_list{get;set;}
public account_opportunity_controller()
{
accList=[select id,name from account limit 100];
}
public List<SelectOption> getItems() {
opt = new List<SelectOption>();
accList=[select id,name from account limit 100];
opt.add(new SelectOption('none','--select--'));
for(Account a:accList)
opt.add(new SelectOption(string.valueof(a.id),a.name));
return opt;
}
public void changeList()
{
id accid=id.valueof(Val);
con_list=new list<contact>();
opp_list=new list<opportunity>();
acc_final_list =[select id,name,(select name from contacts) from account where id=: accid];
}
}
Kindly mark one of the answers above as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
public class AccContactController {
public Id selectedAccId{get;set;}
public Id selectedConId{get;set;}
public List<Contact> conlist {get;set;}
public List<SelectOption> getAccountNames() {
List<SelectOption> accOptions= new List<SelectOption>();
system.debug(selectedAccId);
accOptions.add( new SelectOption('','--Select--'));
for(Account acc : [select Id,name from Account ] ) {
accOptions.add(new SelectOption(acc.Id,acc.name));
}
return accOptions;
}
public List<SelectOption> getContactNames() {
System.debug('Entered ContactNames account id...........'+selectedAccId );
List<SelectOption> conOptions= new List<SelectOption>();
List<SelectOption> options = new List<SelectOption>();
if(selectedAccId != null)
{
for( contact con : [select Id,name,accountid from contact where accountid=:selectedAccId ] ) {
conOptions.add( new SelectOption(con.Id,con.name));
}
}
else
{
conOptions.add( new SelectOption('--None--','--None--'));
}
return conOptions;
}
}
Please try the below code, it is working fine.
Visualforce:
Controller:
I hope it helps you.
Kindly let me inform if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas
Try this..
VF Page..
Controller
Hope this helps...
Kindly mark one of the answers above as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Thanks and regards,
Khan Anas
You can try the following code :
Controller: Please mark as best answer if it helps you.
Thank You
Ajay Dubedi