[SalesForce] How to display fields of an Object record in one column (one below other) in a visualforce page

This should be simple… I guess. I would like to display the fields of an Object record in one column (one below other) in a visualforce page. That is:

-Company Name- -ABC Company-
-Address- -123 Main St-
-Field 3 Description- -Field 3 Value-
-Field 4 Description- -Field 4 Value-
.
.
.
Similar to like how Salesforce displays in its native pages.

Currently I have all the field descriptions hardcoded as headers in a apex:column along with its value. It displays the data, but two problems:
1. It displays all the field values in one ROW with descriptions as headers.
2. I hate to hardcode the field descriptions. Is there a way to programmatically pull that value? That is, if {Obj.field_value__c} pulls the value of the specified field, what is the syntax to pull its corresponding field description from Salesforce?

I would like to do this in a PageBlockTable, of course not using BR and TABLE tags. I am sure there is a cleaner way to do this… can someone tell me how?

EDIT: How to set the width to 100% when there are more than one such pageBlocks in a single row?

enter image description here

Best Answer

I think you're confused with your tags... <apex:pageBlockTable> is used for tables, for the regular UI style layout you want <apex:pageBlock> and <apex:pageBlockSection>.

Note the use of columns="1" in the section to get the layout you're after, and using <apex:outputField> takes care of the field label for us too. You'll need to use the right merge fields of course, but this should get you where you want to go:

<apex:pageBlock title="The Details">
  <apex:pageBlockSection columns="1">
    <apex:outputField value="{!Obj.Name}"/>
    <apex:outputField value="{!Obj.Address__c}"/>
    <apex:outputField value="{!Obj.Field_3__c}"/>
    <apex:outputField value="{!Obj.Field_4__c}"/>
  </apex:pageBlockSection>
</apex:pageBlock>