[SalesForce] How to get the field label name from field set

How to get the field label name from field set. I have created a fields set for custom object and I am trying to get the fiedset to display on VF page and I am able to get the fieldset display on VF page but now my requirement is to get the field Label. How can I get the field label name on VF page please guide me hoe can I get this working.

Best Answer

If f is the reference to a field within the fieldset, then all you need is f.label.

Example straight from the docs:

<apex:pageBlockTable value="{!$ObjectType.Contact.FieldSets.properNames}" var="f">
    <apex:column value="{!f}">
        <apex:facet name="header">Name</apex:facet>
    </apex:column> 
    <apex:column value="{!f.Label}">
        <apex:facet name="header">Label</apex:facet>
    </apex:column> 
    <apex:column value="{!f.Type}" >
        <apex:facet name="header">Data Type</apex:facet>
    </apex:column> 
</apex:pageBlockTable>

Other things you can reference in Visualforce:

DBRequired  Indicates whether the field is required for the object
FieldPath   Lists the field’s spanning info
Label       The UI label for the field
Required    Indicates whether the field is required in the field set
Type        The data type for the field