Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
chanti k asked in #Apex
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 

Thanks,

Chanti
2 answers
  1. Mar 3, 2017, 11:20 AM
    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

        {

            get;

            set;

        }

        public shows20recordsapex() {

            AccList = [Select id,Name,Phone from Account limit 20];

        }

    }

    Visualforce Page as shown below :

    <apex:page controller="shows20recordsapex">

        <apex:form>

            <apex:pageBlock title="20 Records of Accounts">

                    <table border="2px">

                        <tr>

                            <th>Id</th>

                            <th>Name</th>

                            <th>Phone</th>

                        </tr>

                <apex:repeat value="{!accList}" var="a" >

                        <tr>

                            <td>{! a.Id}</td> 

                         <td>{! a.Name}</td>

                            <td>{! a.phone}</td>

                        </tr>

                </apex:repeat>

                        </table>

            </apex:pageBlock>

        </apex:form>

    </apex:page>

    Hope it helps you.

     

     Regards,

     Akshay
Loading
0/9000