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

String.name error
I am at a lost for some reason this code will not work and I don't understand why. I am trying to make a table on a visual force page.
Here is the class
public with sharing class stationController
{
public List<Account> accounts {get;set;}
public stationController()
{
accounts = [SELECT Id, Name, Customer_Num__c, Location_Number__c, Type FROM account LIMIT 10];
}
}
and here is the page
<apex:page controller="stationController">
<apex:pageBlock title="Stations">
<apex:pageBlockTable value="{!accounts}>" var="account">
<apex:column value="{!accounts.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
The class shows no problem but when I try to get the account name on the visual force page I get the string.name error but if I only call for the account I get teh account ID number just fine.
I have used the exact same code to get contact information and this error never appeared.
Here is the class
public with sharing class stationController
{
public List<Account> accounts {get;set;}
public stationController()
{
accounts = [SELECT Id, Name, Customer_Num__c, Location_Number__c, Type FROM account LIMIT 10];
}
}
and here is the page
<apex:page controller="stationController">
<apex:pageBlock title="Stations">
<apex:pageBlockTable value="{!accounts}>" var="account">
<apex:column value="{!accounts.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
The class shows no problem but when I try to get the account name on the visual force page I get the string.name error but if I only call for the account I get teh account ID number just fine.
I have used the exact same code to get contact information and this error never appeared.
<apex:pageBlock title="Stations">
<apex:pageBlockTable value="{!accounts}>" var="account">
<apex:column value="{!accounts.name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Can you remove s from the highlighted one and try ?
Yes as per Amitsahu you are using {!accounts} which is a list and you are refering accounts.name which is wrong.
-Thanks
Ashlekh Gera