+ Start a Discussion
chanti kchanti k 

How to display the table as a vertical in visual force page.

Hi All,

i want display the table as a vertical in visualforce page. pls demonstration this how to we can achive this.Give me example code 

Hello Chanti,

Here is an example for building a table in visualforce:
<apex:page standardController="Account">
   <apex:pageBlock title="Hello {!$User.FirstName}!">
      You are viewing the {!account.name} account.
   <apex:pageBlock title="Contacts">
      <apex:pageBlockTable value="{!account.Contacts}" var="contact">
         <apex:column value="{!contact.Name}"/>
         <apex:column value="{!contact.MailingCity}"/>
         <apex:column value="{!contact.Phone}"/>

If you want to use Custom Controller try as shown below:
//Example APEX CLASS 
public class opportunityList2Con {
    // ApexPages.StandardSetController must be instantiated
    // for standard list controllers
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SELECT Name, CloseDate FROM Opportunity]));
            return setCon;

    // Initialize setCon and return a list of records
    public List<Opportunity> getOpportunities() {
        return (List<Opportunity>) setCon.getRecords();

//The following Visualforce markup shows how the custom controller above can be used //in a page:

<apex:page controller="opportunityList2Con">
        <apex:pageBlockTable value="{!opportunities}" var="o">
            <apex:column value="{!o.Name}"/>
            <apex:column value="{!o.CloseDate}"/>

Note: Please mark this as best answer if this help you resolve.
you can show the record via two ways:-
     1. By using Salesforce Record
     2. By using Manual Record
In below example I am using Account record in Salesforce,

Custom Controller as shown below :
public class shows20recordsapex {
    public List<Account> AccList
    public shows20recordsapex() {
        AccList = [Select id,Name,Phone from Account limit 20];
Visualforce Page as shown below :
<apex:page controller="shows20recordsapex">
        <apex:pageBlock title="20 Records of Accounts">
                <table border="2px">
            <apex:repeat value="{!accList}" var="a" >
                        <td>{! a.Id}</td> 
                        <td>{! a.Name}</td>
                        <td>{! a.phone}</td>
Hope it helps you.