Sometimes we need to display data from different objects (not related to each other) in a table. Best way to do that is using wrapper class. I am showing you an example where i am displaying records from contact and account object ( i am not using their r/ship, so it could be any two object)
Page:
Controller:
Page:
<apex:page controller="Deleteme7_controller" >
<apex:pageBlock >
<apex:pageblocktable value="{!final}" var="a">
<apex:column value="{!a.acc.name}" />
<apex:column value="{!a.con.name}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:page>
Controller:
public with sharing class Deleteme7_controller {
List final3 = new list();
wrapclass wrapobject;
public Deleteme7_controller (){
list a= [select id,name from account];
list c = [select name,id from contact];
add(a,c);
}
public list getFinal(){
return final3;
}
public void add(list a,list b){
integer j=0;
public class wrapclass{
public account acc{get;set;}
public contact con{get;set;}
}
}
Hi,
ReplyDeleteUsing wrapper class how to display Field LableName,Api Name and data type using visualforce page and apex class.
please help me.............