You need to sign in to do that
Don't have an account?
sainath .chalamcherla
output
After clicking on AccountQuery or ContactQuery I am getting the following output
soql query output in visualforce
Hi, I got strucked in this example.I want to show the SOQL query result in table format in visualforce. Apex Code: public class AccountClass1 { public list<Account> acc{get;set;} public List<Contact> ccc{get;set;} public List<Account> AccountClass2() { List<Account> acc = [select Name,Phone,Type from Account where Name='capital first']; return acc; } public List<Contact> AccountClass3() { List<Contact> ccc = [SELECT AccountId,Name FROM Contact where AccountId IN(select Id from Account where Name='capital first')]; return ccc; } }VIsualForce Code:
<apex:page controller="AccountClass1" sidebar="True" showHeader="true"> <apex:form > <apex:commandButton action="{!AccountClass2}" value="Accountquery" id="ss"/> <apex:pageBlock> <apex:pageblockTable value="{!acc}" var="a" id="ss"> <apex:column value="{!a.Name}"/> <apex:column value="{!a.Phone}"/> <apex:column value="{!a.Type}"/> </apex:pageblockTable> </apex:pageBlock> <apex:commandButton action="{!AccountClass3}" value="Contactquery" id="ds" /> <apex:pageBlock> <apex:pageblockTable value="{!ccc}" var="c" id="ds"> <apex:column value="{!c.AccountId}"/> <apex:column value="{!c.Name}"/> </apex:pageblockTable> </apex:pageBlock> <script> </script> </apex:form> </apex:page>
output
After clicking on AccountQuery or ContactQuery I am getting the following output
public List<Account> AccountClass2() {
acc = [select Name,Phone,Type from Account where Name='capital first'];
return acc;
}
All Answers
public List<Account> AccountClass2() {
acc = [select Name,Phone,Type from Account where Name='capital first'];
return acc;
}