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
prasanth kumarprasanth kumar 

visualforce not displaying apex query data

Error: Unknown property 'zipcodes2.acclst'      this is the error showing in visual force page.  
 









apex: code:
public class zipcodes2 {
public integer count{set;get;}
List acclst{set;get;}

public zipcodes2()
{
accLst = [select id from Postal_codes__c limit 3000] ;

    }

}

 
James LoghryJames Loghry
By default, variables are private.  This means only the Apex class can see them. You'll need to update your acclst to be public in order for your Visualforce page to see the variable.  Change line 3 in your code the following, and it should work, barring other errors:
 
public List acclst{get; private set;}

 
Subhani_SFDCSubhani_SFDC
Hi You need to declare the list as

public list acclst{get;set;}

check the above line
Subhani_SFDCSubhani_SFDC
Actually, we can use the above two ways as per our requirement.

1. public List acclst{get; private set;}

if we declare the list in the above we cannot set the List from another class/controller. we can only set the value from the declation class/controller

2. public List acclst{get;set;}

the above declaration helps us to set the List from any other class/controller related to that salesforce instance.