You need to sign in to do that
Don't have an account?

I am Getting unknown property error while accessing the wrapper class member using object.Please suggest me where I am going wrong?
Public Class AccountSelected {
Public List<AccWrap>AccList {get;set;}
Public AccountSelected (){
List<Account> AccRecords=[Select ID, Name From Account];
for(Account c:AccRecords){
AccList.add(new AccWrap(c));
}
}
public class AccWrap{
Public Account Acc;
Public Boolean CheckBoolean;
Public AccWrap(Account a){
Acc=a;
CheckBoolean=false;
}
}
}
//////////////////////////
<apex:page controller="AccountSelected ">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!AccList}" var="d">
<apex:column value="{!d.Acc.name}" />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Public List<AccWrap>AccList {get;set;}
Public AccountSelected (){
List<Account> AccRecords=[Select ID, Name From Account];
for(Account c:AccRecords){
AccList.add(new AccWrap(c));
}
}
public class AccWrap{
Public Account Acc;
Public Boolean CheckBoolean;
Public AccWrap(Account a){
Acc=a;
CheckBoolean=false;
}
}
}
//////////////////////////
<apex:page controller="AccountSelected ">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!AccList}" var="d">
<apex:column value="{!d.Acc.name}" />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Please try the below code.
// Apex Class
Public Class AccountSelected {
Public List<AccWrap>AccList {get;set;}
Public AccountSelected (){
AccList = new List<AccWrap>();
List<Account> AccRecords=[Select ID, Name From Account limit 5];
for(Account c:AccRecords){
AccList.add(new AccWrap(c));
}
}
public class AccWrap{
Public Account Acc{get;set;}
Public Boolean CheckBoolean{get;set;}
Public AccWrap(Account a){
Acc=a;
CheckBoolean=false;
}
}
}
// VF Page
<apex:page controller="AccountSelected">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!AccList}" var="d">
<apex:column headerValue="Select Checkbox">
<apex:inputCheckbox value="{!d.CheckBoolean}" />
</apex:column>
<apex:column value="{!d.Acc.name}" />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Please select this answer as best if you find it helpful.
Thank You,
Ajay Dubedi