Here i have provided code sample to understand, how to display data from custom objects to PageBlockTable. I have chosen pageBlocktable because it has predefined style. Don't want to use any css styles for that.
Apex Design Code:
- <apex:page controller="ViewUserController">
- <apex:form >
- <apex:sectionHeader subtitle="All Users" title="Users" />
- <apex:pageBlock >
- <apex:pageBlockTable value="{!allusers}" var="a">
- <apex:column headervalue="Name" value="{!a.Name__c}" />
- <apex:column headervalue="Age" value="{!a.Age__c}" />
- <apex:column headervalue="Class" value="{!a.Class__c}" />
- </apex:pageBlockTable>
- </apex:pageBlock>
- </apex:form>
- </apex:page>
Apex Controller Code:
- public class ViewUserController
- {
- public List<User__c> allusers;
- public List<User__c> getAllUsers()
- {
- if(allusers==null)
- {
- allusers=[SELECT Name__c,Age__c,Class__c from User__c];
- }
- return allusers;
- }
- }
No comments:
Post a Comment