You need to sign in to do that
Don't have an account?
Satya413
Display Selected Account Record Details in VF Page
Hi,
I am trying to display the account details ( name, address, phone ) for the account selected in picklist. I have written the code for picklist as below. Any help is appreciated.
<apex:page Controller="accountcontroller" showHeader="false">
<apex:form>
<apex:pageBlock title="Display Account Details: ">
<apex:pageBlockSection>
<apex:outputLabel value="Account Name: " />
<apex:selectlist value="{!accid}" size="1" >
<apex:selectOptions value="{!accountnames}" />
<apex:actionSupport event="onchange" rerender = "display"/>
</apex:selectlist>
</apex:pageBlockSection>
<apex:pageBlockSection title = 'Account Details'>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller
public class accountcontroller {
public string accid {get; set;}
public list<selectoption> getaccountnames() {
list<selectoption> accoptions = new list<selectoption>();
for (account acc : [select id, name from account]){
accoptions.add(new selectoption(acc.id, acc.name));
}
return accoptions;
}
}
Thank you,
Satya
I am trying to display the account details ( name, address, phone ) for the account selected in picklist. I have written the code for picklist as below. Any help is appreciated.
<apex:page Controller="accountcontroller" showHeader="false">
<apex:form>
<apex:pageBlock title="Display Account Details: ">
<apex:pageBlockSection>
<apex:outputLabel value="Account Name: " />
<apex:selectlist value="{!accid}" size="1" >
<apex:selectOptions value="{!accountnames}" />
<apex:actionSupport event="onchange" rerender = "display"/>
</apex:selectlist>
</apex:pageBlockSection>
<apex:pageBlockSection title = 'Account Details'>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller
public class accountcontroller {
public string accid {get; set;}
public list<selectoption> getaccountnames() {
list<selectoption> accoptions = new list<selectoption>();
for (account acc : [select id, name from account]){
accoptions.add(new selectoption(acc.id, acc.name));
}
return accoptions;
}
}
Thank you,
Satya
If you get the answer, please mark it as the correct answer. It will be a help to others who are facing the same problem later.
All Answers
If you get the answer, please mark it as the correct answer. It will be a help to others who are facing the same problem later.
Thanks for your help. I am able to get the account details now.
Thank you,
Satya
I tried your code and I got an error Constructor not defined. What should I do