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

"dataTable" return empty data
Hello,
I have an problem. I try to use data table apex function in my page, but show me empty always. The controller return good data, but something happens in "apex:dataTable". This is my code:
<apex:page controller="exampleCon" cache="false">
<apex:dataTable value="{!contacts}" var="c" id="theTable" rowClasses="odd,even" styleClass="tableClass">
<apex:column><apex:facet name="header">Name</apex:facet>
<apex:outputText value="-{!c.Name}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Phone</apex:facet>
<apex:outputText value="-{!c.Phone}"/>
</apex:column>
</apex:dataTable>
</apex:page>
And my controller:
public class exampleCon {
List<Contact> contacts;
public List<Contact> getcontacts() {
contacts = [select Name, Phone from Contact limit 10];
return contacts;
}
}
Thanks.
Check whether you have permission to read Contact object and its fields
All Answers
Hi
You have to use getContacts() instead of getCases.OR You have to change the datatable value in VFpage to cases instead of contacts. and You have to write list<Contact> contacts=new list<Comntact>();
Thanks
I change the function name to getContacts(), but this continue to fail.
Hi
Use list<contact> contacts=new list<contact>(); or you can directly use list<contact> contacts=[select.......]; in get method
thanks.
Dont work.
If I try to extract information and put is in a variable, work perfectly:
I add this in my controller:
String Phone;
.......................
public String getPhone() {
Phone = contacts.get(0).Phone;
return Phone;
}
And in my page:
<apex:outputText value="{!Phone}"/>
And show me a phone number.
there is no problem its working Properly. i didn't get what u want?
I want to show a list of contacts using apex:dataTable. I try to say you that do not fail in apex class, fail in the apex page.
Thanks
everything is looking fine in your code, please verify if your query is returning some results.
Check whether you have permission to read Contact object and its fields
I have a Trial Enterprise account, this affects?
it shouldnt. please post your entire code.
I guess its some security issue, Same code works perectly in my org.
Thanks, now work perfectly.