You need to sign in to do that
Don't have an account?
![Vignesh Ramshetty Vignesh Ramshetty](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
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](/forums/servlet/rtaImage?eid=9062I000000UkfG&feoid=Body&refid=0EM2I000001TdTV)
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>
you can either use same wrapper or can create a seprate wrapper class for your second object, just like below code :
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,