function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vignesh RamshettyVignesh Ramshetty 

Unable to display account records Below is the code and the screenshot for ur refeernce

APEX CLASS:

Public class Sample321{

Public List<Wapperclass> ListWrapper {set;get;}



public Sample321(){



List<Property__c> listtec = [SELECT Name FROM Property__c LIMIT 10];
List<Account> listacc = [SELECT Name FROM Account LIMIT 5];

 

   if(listacc.size() > 0){

      ListWrapper = new List<Wapperclass>();

        for(Account a : listacc){
          ListWrapper.add(new Wapperclass(a));
  }


}
     if(listtec.size() > 0){

      ListWrapper = new List<Wapperclass>();

        for(Property__c T : listtec ){
          ListWrapper.add(new Wapperclass(T));
  }


}

}

public class Wapperclass {
Public Boolean checkbool {get;set;}
Public Account acct {get;set;}
Public Property__c tecc {get;set;}

Public Wapperclass (Property__c tecc){
        this.tecc  = tecc;

}
Public Wapperclass (Account  acct){
        this.acct = acct;
        }

}

}


VISUALFORCE PAGE : 
<apex:page Controller="Sample321">
<apex:form >
<apex:pageBlock title="List Data">
<apex:pageMessages />
<apex:pageBlockSection >
<apex:pageBlockTable value="{!ListWrapper}" var="me" >
<apex:column > <apex:inputCheckbox value="{!me.checkBool}"/> </apex:column>
<apex:column value="{!me.acct.Name}"/>
<apex:column value="{!me.tecc.Name}"/>

</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

User-added image
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

you can either use same wrapper or can create a seprate wrapper class for your second object, just like below code :
 
Public class Sample321{

Public List<Wapperclass> ListWrapper {set;get;}
Public List<Wapperclass> ListWrapper2 {set;get;}


public Sample321(){



List<Airplane__c> listtec = [SELECT Name FROM Airplane__c LIMIT 10];
List<Account> listacc = [SELECT Name FROM Account LIMIT 5];

 

   if(listacc.size() > 0){

      ListWrapper = new List<Wapperclass>();

        for(Account a : listacc){
          ListWrapper.add(new Wapperclass(a));
  }


}
     if(listtec.size() > 0){

      ListWrapper2 = new List<Wapperclass>();

        for(Airplane__c T : listtec ){
          ListWrapper2.add(new Wapperclass(T));
  }

system.debug('asas'+ListWrapper);
}

}

public class Wapperclass {
Public Boolean checkbool {get;set;}
Public Account acct {get;set;}
Public Airplane__c tecc {get;set;}

Public Wapperclass (Airplane__c tecc){
        this.tecc  = tecc;

}
Public Wapperclass (Account  acct){
        this.acct = acct;
        }

}

}
 
<apex:page Controller="Sample321">
<apex:form >
<apex:pageBlock title="List Data">
<apex:pageMessages />
<apex:pageBlockSection >
<apex:pageBlockTable value="{!ListWrapper}" var="me" >
<apex:column > <apex:inputCheckbox value="{!me.checkBool}"/> </apex:column>
<apex:column value="{!me.acct.Name}"/>
<apex:column value="{!me.tecc.Name}"/>

</apex:pageBlockTable>
    <apex:pageBlockTable value="{!ListWrapper2}" var="me" >
<apex:column > <apex:inputCheckbox value="{!me.checkBool}"/> </apex:column>
<apex:column value="{!me.acct.Name}"/>
<apex:column value="{!me.tecc.Name}"/>

</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,