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
Uday Kiran 109Uday Kiran 109 

When i'm trying to execute below it's showing{Error: Compile Error: Variable does not exist: name at line 8 column 9} please help me out.

Class:
   
 public class ListExample3 {
    public string name{set;get;}
    public string industry{set;get;}
    public string phone{set;get;}
    public ListExample3(){
        List<Account>accs=new List<Account>();
        Account a1=new Account();
        a1.name='Wipro';
        a1.industry='Information Technology';
        a1.phone='123';
        accs.add(a1);
        Account a2=new Account();
        a2.name='TCS';
        a2.industry='Banking';
        a2.phone='123';
        accs.add(a2);
    }

}

VF page:
 
<apex:page controller="ListExample3">
    <apex:form>
    <apex:pageBlock title="Account">
        <apex:pageBlockTable value="{!accs}" var="a">
            <apex:column value="{!a.name}"/>
            <apex:column value="{!a.industry}"/>
            <apex:column value="{!a.phone}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
sfdcMonkey.comsfdcMonkey.com
hi uday
try this code
<apex:page controller="ListExample3">
    <apex:form>
    <apex:pageBlock title="Account">
        <apex:pageBlockTable value="{!accs}" var="a">
            <apex:column value="{!a.name}"/>
            <apex:column value="{!a.industry}"/>
            <apex:column value="{!a.phone}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public class ListExample3 {
    public string name{set;get;}
    public string industry{set;get;}
    public string phone{set;get;}
    public List<Account>accs{set;get;} 
    public ListExample3(){
      accs = new List<Account>();
        Account a1=new Account();
        a1.name='Wipro';
        a1.industry='Information Technology';
        a1.phone='123';
        accs.add(a1);
        Account a2=new Account();
        a2.name='TCS';
        a2.industry='Banking';
        a2.phone='123';
        accs.add(a2);
    }

}
create accs as a public property and then use it in vf page
I hop it helps you
Mark it best answer if it helps you
Thanks


 
Uday Kiran 109Uday Kiran 109
Thank you, Piyush!!
sfdcMonkey.comsfdcMonkey.com
pleasure if my Answer helps you Please mark it best answer  so it make proper solution for others in future :)
Thanks
Uday Kiran 109Uday Kiran 109
Piyush, i really appreciate your helping nature. I had tried the code what you suggest but i'm getting the same error.