+ Start a Discussion
deepak balur 19deepak balur 19 

VisualForce Error: Unknown Property error

Keep getting the error unknown property: AccountController.DisplayAccount.operations_status__c

Have a page block as follows:
    <apex:pageBlockTable title="Account" value="{!Accntlist}" var="Accnts">
                
                      <apex:column headerValue="Id" value="{!Accnts.Id}" />
                    <apex:column headerValue="Name" value="{!Accnts.Name}" />
                       <apex:column headerValue="Status" value="{!Accnts.Operations_Status__c}" />
                       
            </apex:pageBlockTable>

Controller so far is at:

public class AccountController {
    
     public Static List<DisplayAccount> getAccntlist() {

         List <DisplayAccount> Accntlist = new List<DisplayAccount>();
         for (Account A : [SELECT Id, Name,Operations_Status__c  FROM Account]){
             Accntlist.add(new DisplayAccount(A));
         }
            return Accntlist;
     }
    
    public class DisplayAccount{
        private Account VAccnt;

        public DisplayAccount(Account A) {
            this.VAccnt = A;
        }

        public String ID {
            get { return VAccnt.Id; }
        }

        public String Name {

            get { return VAccnt.Name; }

        }
    
        public String Status {

            get { return VAccnt.Operations_Status__c; }

        }}//End of Class Display Account
    
 public PageReference addToCart() {
    return null;
   
}//End of AddtoCart

}//End of Class
Best Answer chosen by deepak balur 19
RaidanRaidan
Hi Deepak,

In your code, there is no direct relationship from DisplayAccount to Operation_Status__c. However, you set the Operation_Status__c to Status property. So, in your Visualforce, you can call either:

<apex:column headerValue="Status" value="{!Accnts.Status}" />
or
<apex:column headerValue="Status" value="{!Accnts.VAccnt.Operations_Status__c}" />
 

All Answers

@Karanraj@Karanraj
In the wrapper class you have used 'Status' instead of the Operations_Status__c but in the visualforce page, you have used the API name of the field. Try the below updated visualforce page code
<apex:pageBlockTable title="Account" value="{!Accntlist}" var="Accnts">
   <apex:column headerValue="Id" value="{!Accnts.Id}" />           
   <apex:column headerValue="Name" value="{!Accnts.Name}" />                  
   <apex:column headerValue="Status" value="{!Accnts.Status}" />                 
</apex:pageBlockTable>                         

 
RaidanRaidan
Hi Deepak,

In your code, there is no direct relationship from DisplayAccount to Operation_Status__c. However, you set the Operation_Status__c to Status property. So, in your Visualforce, you can call either:

<apex:column headerValue="Status" value="{!Accnts.Status}" />
or
<apex:column headerValue="Status" value="{!Accnts.VAccnt.Operations_Status__c}" />
 
This was selected as the best answer
PavanKPavanK
Could you please try to update variable type public instead of private.

For ex:
 private Account VAccnt;

to

 public Account VAccnt;