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
Aman Kumar 196Aman Kumar 196 

I wrote the below code, and getting the Unknown property "'SearchAccount_ctrl.AccList'" Error.

public class SearchAccount_ctrl {
    
    public string city{get;set;}
    public Boolean show{get;set;}
    public integer size{get;set;}
   List<Account> AccList{get;set;}
    
    Public SearchAccount_ctrl()
    {
        Size=0;
        Show=False;
        AccList=new List<Account>();
    }
    
    Public void Search()
    {
        AccList=[Select id,Name,Rating,Industry From Account where Billingcity=:city];
        Size= AccList.size();
        If(size>0)
        {
            show=true;    
        }
        else
        {
            show=false;
        }
        
    }

}
=======================
VF Page:
<apex:page controller="SearchAccount_ctrl">
    <apex:form>
        <apex:pageBlock>
            <apex:pageblocksection >
                <apex:outputLabel id="a1">
                    <apex:pageblocktable title='Search Result' value="{!AccList}" var="item">
                      <apex:column value="{!item.Name}"/>  
                      <apex:column value="{!item.Billingcity}"/> 
                      <apex:column value="{!item.Rating}"/> 
                      <apex:column value="{!item.Industry}"/> 
                    </apex:pageblocktable>
                </apex:outputLabel>
            </apex:pageblocksection>
            <apex:commandButton title="Search" action="{!Search}"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Best Answer chosen by Aman Kumar 196
MoonpieMoonpie
You have declared cityshow and size as public, but not AcctList.

Try adding public.

All Answers

MoonpieMoonpie
You have declared cityshow and size as public, but not AcctList.

Try adding public.
This was selected as the best answer
MoonpieMoonpie
Hi Aman,

Did you try what I suggested?  If so, did it work?
Or did you do something else that worked?
Or do you still have the problem?

Please update.

Thanks!
Aman Kumar 196Aman Kumar 196
Thank you Moonpie, It worked.