You need to sign in to do that
Don't have an account?
display the field from custom object, To be display in Visualforce using Custom controller.
Hi Everyone,
I want to display the field from my custom object(Timesheet__c), To be display in Visualforce using Custom controller.
Below is my VF:
<apex:page controller="ManagementTime" lightningStylesheets="true" >
<apex:form >
<apex:pageBlock >
<apex:pageblockSection columns="1" >
<apex:pageblockTable value="{!objlist}" var="c" >
<apex:column headervalue="Task" >
<apex:inputField value="{!c.Task_Type__c}"/>
<apex:outputField value="{!c.Task_Type__c}" />
</apex:column>
<apex:column headervalue="Monday" rendered="true" >
<apex:inputField value="{!c.Monday__c}"/>
<apex:outputField value="{!c.Monday__c}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Below is my Custom controller:
public class ManagementTime{
public list<Timesheet__c> objlist {get;set;}
public ManagementTime(){
objlist = [SELECT Id, Task_Type__c FROM Timesheet__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
}
}
But I my getting only header name:
But I want like this:
Could someone help me in this? I am new to visualforce development.Thank you in advance!
Try below :
<apex:page controller="ManagementTime" lightningStylesheets="true" >
<apex:form >
<apex:pageBlock >
<apex:pageblockSection columns="1" >
<apex:pageblockTable value="{!objlist}" var="c" >
<apex:column headervalue="Task">
<apex:inputField value="{!c.Task_Type__c}"/>
</apex:column>
<apex:column headervalue="Monday">
<apex:inputField value="{!c.Monday__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks.
Hi Vishwajeet,
This is also not working. It is working as same before.
Please help me in this!
Hi Shavi Dabgotra,
please find the solution
If you find this solution is helpful for you please mark the best answer
Hi Malika Pathak,
I have tried your sample code as well. But it is displaying the same. Could you help me in this?
Thank you!
Below works for me. i see that one of the field - "Monday__c" is not queried in controller method, may be that's the issue.
<apex:page controller="ManagementTime" lightningStylesheets="true" >
<apex:form >
<apex:pageBlock >
<apex:pageblockSection columns="1" >
<apex:pageblockTable value="{!objlist}" var="c" >
<apex:column headervalue="Task">
<apex:inputField value="{!c.Task_Type__c}"/>
</apex:column>
<apex:column headervalue="Monday">
<apex:inputField value="{!c.Monday__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Hi Vishwajeet,
That is working when we provide Id in the URL. But I want the empty feilds when we load the VF page. Can you help me in this? Thank you!