0

I have Written the Visual Force Page Coding :

<apex:page standardController="Contact">
    <apex:form >
        <apex:pageBlock>
            <apex:pageBlockButtons location="top">
                <apex:commandButton action="{!Cancel}" value="Back"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection >
                <apex:pageBlockTable id="sampleGrid" value="{!Contact.AccountId}" var="a">
                    <apex:inputfield label="Account"  value="{!Contact.AccountId}" />
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

output: it is Showing only one Grid line , but it is Not Displaying the lookupField on the Visual Force Page, How to Rectify the Error, Anyone Guide Me for the Answer

  • Your code is messy. Do you want to display one record or a list of records? – Lance Shi Aug 18 '16 at 6:38
  • I want to display the Lookup field Label in visual force page How – SFDC Aug 18 '16 at 6:40
  • Just replace your <apex:pageBlockTable> section with a single <apex:inputfield label="Account" value="{!Contact.AccountId}" />. It will be working – Lance Shi Aug 18 '16 at 6:50
  • I guess pageblock table always use list os sobject or wrapper not the single field like above Contact.AccountId – Ratan Paul Aug 18 '16 at 6:50
  • @Ratan single field is Not possible in apex Page block Table – SFDC Aug 18 '16 at 6:56
1

The way you use the pageBlockTable is little confusing as I see. You have to add apex:column tag in order to bring the columns of the table. Try below code for the table. This way you can add more columns to your table.

<apex:pageBlockTable id="sampleGrid" value="{!Contact.AccountId}" var="a">
    <apex:column >
        <apex:facet name="header">Account</apex:facet>
        <apex:inputfield label="Account"  value="{!Contact.AccountId}" />
    </apex:column>
</apex:pageBlockTable>

When you use pageBlockTable, the advantage is to bind dynamic values of a list into rows by using the value and var attribute value. Check the documentation linked. This is not being used in the code anyway. Hope you are in a mid of a development.

  • The code will be working. But it doesn't make any sense to use pageBlockTable here. – Lance Shi Aug 18 '16 at 6:43
  • Header Name is displaying , how to display lookup field text box is Not showing on the Grid – SFDC Aug 18 '16 at 6:45
  • Label and Lookup field Value is Not Displaying on the Grid, – SFDC Aug 18 '16 at 6:48
  • @user36188 : when using Apex:pageblocktable , label will not appear, as it is already comes as header of table. – Ankuli Aug 18 '16 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.