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
bhanu reddy 24bhanu reddy 24 

how to write page block table

Avishek Nanda 14Avishek Nanda 14
Hi Bhanu,

Below Snippet would render a pageBlock Table.
<apex:page standardController="Account">
   <apex:pageBlock title="Hello {!$User.FirstName}!">
      You are viewing the {!account.name} account.
   </apex:pageBlock>
   <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}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:page>

For more details: 
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_iteration_components.htm

Mark this as your best answer if this resolves your query.

Regards,
Avishek Nanda
bhanu reddy 24bhanu reddy 24
thank you so much responding me
bhanu reddy 24bhanu reddy 24
one page block table   show data multipule objects how to write? not only contact
contact object contact name
Account object Account name,Amountfield
opportunity object Opportunity name
 
Avishek Nanda 14Avishek Nanda 14
Hey Bhanu,

You need to use Wrapper class to store the details. and Use table inside table to show the details.

Regards,
Avishek
bhanu reddy 24bhanu reddy 24
thank you for responding me
bhanu reddy 24bhanu reddy 24
can you plzz write a program
Avishek Nanda 14Avishek Nanda 14
Something Like this
<apex:pageBlock title="Accounts and Contacts">
            <table border="1">
                <tr>
                	<th>Account Name</th>
                    <th>First Name</th>
                    <th>Last Name</th>
                    <th>City</th>
                    <th>State</th>
                </tr>
                <apex:repeat value="{!accounts}" var="a">
                    <tr>
                        <td>{!a.Name}</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <apex:repeat value="{!a.Contacts}" var="c">
                        <tr>
                            <td>&nbsp;</td>
                            <td>{!c.FirstName}</td>
                            <td>{!c.LastName}</td>
                            <td>{!c.MailingCity}</td>
                            <td>{!c.MailingState}</td>
                        </tr>
                    </apex:repeat>
                </apex:repeat>
            </table>
        </apex:pageBlock>

 
bhanu reddy 24bhanu reddy 24
thank you for responding me
bhanu reddy 24bhanu reddy 24
sry boss it is not correct ,i am asking just names display in colum header 
contactname
accountname
account amount
opportunityname
can you plz write a table
 
bhanu reddy 24bhanu reddy 24
by using page block table
bhanu reddy 24bhanu reddy 24

<apex:page standardController="Account">
   <apex:pageBlock title="Hello {!$User.FirstName}!">
    You are viewing the {!account.name} account.
  </apex:pageBlock>
  <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}"/>
     </apex:pageBlockTable>
   </apex:pageBlock>
</apex:page>


that is correct but you have only take one object  i want multipule object data