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
hafizsohaibalihafizsohaibali 

Data Not Show in Data table please help me and suggest best answer

Apex Page not Displayed the records in data Table please tell me what is error in my controller class or apex page please

 

This is my Apex Page Code

 

<apex:page id="helloWorld"  showHeader="false"  controller="TableClass" >
  <!-- Begin Default Content REMOVE THIS -->
   <apex:form id="HelloForm">
          Data Base Example
           <apex:outputLabel id="lblID" value="Enter ID"/>
           <apex:inputText required="true" id="txtID" value="{!ID}"/>
           <apex:outputLabel id="lblDescription" value="Enter Description"/>
           <apex:inputText required="true" id="txtdescription" value="{!Description}"/>
           <apex:outputLabel id="lblRecords" value="No of Records"/>
           <apex:outputLabel id="lblNoRecords" value="{!NoOfRecords}"/>
           <br/>
           <apex:outputLabel value="Records"/>
           <br/>
   <apex:dataTable value="{!accounts}" var="c" >
        <apex:column >
            <apex:facet name="header">ID</apex:facet>
            <apex:outputText value="{!c.ID__c}" />
        </apex:column>
    </apex:dataTable>
   </apex:form>
  <!-- End Default Content REMOVE THIS -->
</apex:page>

This my controller Class

 

public class TableClass
{

      private final List<AppHelloO__c> accounts;



    public List<AppHelloO__c> getAccounts() {
        if(accounts == null)
        {
      
        }
        return accounts;

    }
    public Integer ID
    {
        get;
        set;
    }
    public String Description
    {
        get;
        set;
    }
    public String NoOfRecords
    {
        get;
        set;
    }
    private AppHelloObject__c[] atRecords;
  
    public TableClass()
    {
      accounts=new List<AppHelloO__c>();
       
      /*  for(AppHello__c s:atRecords)
        {
           accounts.add(s);
   //        this.NoOfRecords=s.Description__c;
         }*/
         for(Integer i=0; i<7 ;i++)
         {
             AppHelloO__c c=new AppHelloO__c(ID__c=i);
             accounts.add(c);
          
                    this.NoOfRecords=String.valueOf(c.ID__c+10);
           this.ID=1;
   
         }  
        this.Description='Sohaib Ali';
       //   this.atRecords=[SELECT ID__c,Description__c FROM AppHello__c];
       
     //   AppHelloObject__c aaa=new   AppHelloObject__c();
       // aaa.AppHello__c=atRecords[0].id;
                    //atRecords=c;
      //  AppHello__c t=new AppHello__c();
       // t.id=aaa.AppHello__c;           
        this.NoOfRecords=String.valueOf(333);
    }
   
}

<apex:page id="helloWorld"  showHeader="false" tabStyle="AppHelloO__c" controller="TableClass" >
  <!-- Begin Default Content REMOVE THIS -->
   <apex:form id="HelloForm">
          Data Base Example
           <apex:outputLabel id="lblID" value="Enter ID"/>
           <apex:inputText required="true" id="txtID" value="{!ID}"/>
           <apex:outputLabel id="lblDescription" value="Enter Description"/>
           <apex:inputText required="true" id="txtdescription" value="{!Description}"/>
           <apex:outputLabel id="lblRecords" value="No of Records"/>
           <apex:outputLabel id="lblNoRecords" value="{!NoOfRecords}"/>
           <br/>
           <apex:outputLabel value="Records"/>
           <br/>
   <apex:dataTable value="{!accounts}" var="c" >
        <apex:column >
            <apex:facet name="header">ID</apex:facet>
            <apex:outputText value="{!c.ID__c}" />
        </apex:column>
    </apex:dataTable>
   </apex:form>
  <!-- End Default Content REMOVE THIS -->
</apex:page>

Best Answer chosen by Admin (Salesforce Developers) 
samreet_matharu@psl.co.insamreet_matharu@psl.co.in

Well I think the access specifier for accounts list is private so it won't be accessible on page.Try changing that to public.

Thanks,

All Answers

samreet_matharu@psl.co.insamreet_matharu@psl.co.in

Well I think the access specifier for accounts list is private so it won't be accessible on page.Try changing that to public.

Thanks,

This was selected as the best answer
hafizsohaibalihafizsohaibali

thanks i got the solution