Using Wrapper class for displaying records from two objects in a single table

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)

<apex:page controller="Deleteme7_controller" >
<apex:pageBlock >
    <apex:pageblocktable value="{!final}" var="a">
            <apex:column value="{!}" /> 
            <apex:column value="{!}"/>


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];

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;}


1 comment:

  1. Hi,
    Using wrapper class how to display Field LableName,Api Name and data type using visualforce page and apex class.

    please help me.............