You need to sign in to do that
Don't have an account?

PageblockTable
Hi,
In pageBlockTable I want to add few fields from Account and few fields from Contact I have used Account as a standard controller how to give the column values for pageblocktable
in table I want columns for Account Name, Billing address from account object and Name and Email id from Contact object.,
what will be Value and Var details in PageBlockTable, if possible please provide me some example.
Thanks,
Manish.
Hi,
Go through the below code
Visualforce code:
<apex:page controller="AccCon">
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wrapper}" var="wrap">
<apex:column headerValue="Account Name" value="{!wrap.accRec.Name}"/>
<apex:column headerValue="Account Address" value="{!wrap.accRec.BillingStreet}"/>
<apex:column headerValue="Contact Name" value="{!wrap.conRec.Name}"/>
<apex:column headerValue="Contact Email" value="{!wrap.conRec.Email}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Class:
public class AccCon
{
public List<Account> accLst {get; set;}
public List<Contact> conLst {get; set;}
public List<MyWrapper> wrapper {get; set;}
public AccCon()
{
accLst = [select id,name,BillingStreet from account limit 5] ;
conLst = [select id,name,Email from contact limit 5] ;
wrapper = new List<MyWrapper>() ;
for(Integer i=0 ; i < 5 ; i++)
wrapper.add(new MyWrapper(accLst[i] , conLst[i])) ;
}
public class MyWrapper
{
public Account accRec {get; set;}
public Contact conRec {get; set;}
public MyWrapper(Account acc , Contact con)
{
accRec = acc ;
conRec = con ;
}
}
}
and if you have any more questions please feel to contact me on support@groundwireconsulting.com
Sorry for the trouble but I am correcting my query
In pageBlockTable I want to add few fields from Account and few fields from Contact I have used Account as a standard controller how to give the column values for pageblocktable
in table I want columns for Account Name & Billing address from account object and Name & Email id from Contact object. which are associated with that account.
what will be Value and Var details in PageBlockTable, if possible please provide me some example.
Thanks,
Manish.