+ Start a Discussion
Mohammadasif SiddiquiMohammadasif Siddiqui 

I am not getting column name

<apex:page controller="sample1">
    <apex:pageBlock >
         <apex:pageBlockSection columns="1" >
        <apex:pageBlockTable value="{!acct}" var="a"  >
            
                <apex:column headerValue="Action">
                <apex:outputLink value="{!URLFOR($Action.Hospital__c.Edit, a.Id)}">Edit</apex:outputLink>
            </apex:column>           
            <apex:column value="{!a.Name}" />
          
            <apex:repeat value="{!a.Account__r}" var="c" >                
                <apex:column headerValue="Account Name" value="{!c.Name}"></apex:column>
            </apex:repeat>
        </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
 
public class sample1
{    
    public List<Hospital__c> acct {get;set;}
    public sample1()
    {
        acct = [SELECT Name, Account__r.Name FROM Hospital__c];
    }    
}


User-added image

I am not getting the header name "Account Name" like Hospital Name 

I have declared headerValue also in Line 12 also

AnudeepAnudeep (Salesforce Developers) 
Hi,

Please try <apex:column headervalue="{!a.name}"> or <apex:column headervalue="{!c.name}">

If that doesn't work you can try using apex:facet. Below is the sample code
 
<apex:column >
                <apex:facet name="header">Name</apex:facet>
                        {!contact.Name}
</apex:column>
Also found this blog post describing the same issue that might be helpful

https://www.sfdcstuff.com/2014/11/headervalue-not-displayed-in-apex.html

Anudeep

 
David Zhu 🔥David Zhu 🔥
Hi Mo,
You will have to remove <apex:repeat> and change c.Name to a.Account__r.name.
Use the following snipet.

<apex:page controller="sample1">
    <apex:pageBlock >
         <apex:pageBlockSection columns="1" >
        <apex:pageBlockTable value="{!acct}" var="a"  >
            
                <apex:column headerValue="Action">
                <apex:outputLink value="{!URLFOR($Action.Hospital__c.Edit, a.Id)}">Edit</apex:outputLink>
            </apex:column>           
            <apex:column value="{!a.Name}" />
          
            <apex:repeat value="{!a.Account__r}" var="c" >                
                <apex:column headerValue="Account Name" value="{!a.Account__r.Name}"></apex:column>
            </apex:repeat>
        </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>