salesforceapex-codeapexsalesforce-service-cloudsalesforce-chatter

Need to display Fileds in vf page from Query written in Controller


I have a requirement where i need to display fields fetched from query in controller to Vf page without using pageblockTable.

Please see the below code that i am trying.

Apex code :

public class ViewDetailscontroller

{

public List<Course__c> coursesList{get; set;}
public Course__c coursesobj{get; set;}

  public ViewDetailscontroller()

           {

coursesobj =[SELECT Id,Answer_1__c,Web_Score_SwU__c FROM Course__c where Lead__c =: Leadid ];
} 

}

Vf page:

 <apex:page standardController="Lead"  extensions="ViewDetailscontroller" tabStyle="Course__c">

    <apex:form>
      <apex:pageBlock rendered="{!intrestedinData_Analytics}" >
                    <apex:pageBlockSection >

                    <apex:outputField value="{!coursesobj.Batch_for_DA__c}"/>

                    </apex:pageBlockSection>
                    </apex:pageBlock>
    </apex:form>

    </apex:page>

Problem here is i cant bind list values from Controller to pageblock tag or anyother tag apart from pageblocktable.

Please suggest,thanks.


Solution

  • You can use the apex:repeat tag and build your own "table" if you like.

    <apex:repeat value="{!accounts}" var="a">
            <p>{!a.name}, {!a.id}</p>                
    </apex:repeat>