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
karthikarthi 

Reg: How to get the fields of custom object into the pageblock table?

I'm having a custom object called record. i have to get the fields of that in the page block table. My code is below:

 

Controller:

 

Public record__c record {get;set;}

 

VF page:

<apex:pageblock>

<apex:pageblocktable value="{!record}" var="ct">
                   <apex:column headerValue="Year" style="width:102px;" headerClass="centertext">
                            <apex:inputField value="{!ct.Year__c}" >
                            </apex:inputField>
                        </apex:column>
                  <apex:column headerValue="Amount" style="width:102px;" headerClass="centertext">
                            <apex:inputField value="{!ct.Amount__c}" style="width:180px;">
                            </apex:inputField>
                        </apex:column>
                                    </apex:pageblocktable>
               
            </apex:pageBlock>

 

 

But in the pageblock table i'm getting only the header , but not the input fields. Please let me know what i have to do??/

Chamil MadusankaChamil Madusanka

Change your controller as follows

 

public with sharing class testpage18Controller 
{
    Public record__c record {get;set;}
    
    public testpage18Controller()
    {
       record = new record__c();
    }

}

 You need to initialze your attribute.

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.