You need to sign in to do that
Don't have an account?
admin 7
Multiple Objects in Pageblock table using Wrapper class: Error: tt Compile Error: Illegal assignment from List<Account> to List<RNK.account> at line 9 column 9
<apex:page controller="tt">
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wrapper}" var="wrap">
<apex:column headerValue="Account Name" value="{!wrap.accRec.Name}"/>
<!-- you can add related fields here -->
<apex:column headerValue="Contact Name" value="{!wrap.conRec.Name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Controller:
public class tt
{
public List<Account> accLst {get; set;}
public List<Contact> conLst {get; set;}
public List<MyWrapper> wrapper {get; set;}
public tt()
{
accLst = [select id,name from account ] ;
conLst = [select id,name from contact ] ;
wrapper = new List<MyWrapper>() ;
for(Integer i=0 ;i<20;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 ;
}
}
}
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wrapper}" var="wrap">
<apex:column headerValue="Account Name" value="{!wrap.accRec.Name}"/>
<!-- you can add related fields here -->
<apex:column headerValue="Contact Name" value="{!wrap.conRec.Name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Controller:
public class tt
{
public List<Account> accLst {get; set;}
public List<Contact> conLst {get; set;}
public List<MyWrapper> wrapper {get; set;}
public tt()
{
accLst = [select id,name from account ] ;
conLst = [select id,name from contact ] ;
wrapper = new List<MyWrapper>() ;
for(Integer i=0 ;i<20;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 ;
}
}
}
I think, their is Apex class, trigger or something custom in your org with Account name
All Answers
All seems good in your example, Could you check if you have class with name of "account" in your org and that is confusing salesforce.com b/w Standard Account and your custom Account class.
Thanks!
Error: tt Compile Error: Illegal assignment from List<Account> to List<RNK.account> at line 9 column 9
I think, their is Apex class, trigger or something custom in your org with Account name