You need to sign in to do that
Don't have an account?
satakshi
How to display record from custom object on VF Page?
Hello,
I am inserting some records when i click on custom button. Button is on parent object. I am creating child records of that parent object. I want to show all this records on visualforce page. I have written the code. But nothing is displaing. Can anyone please help me?
VF SHOWDTP
<apex:page standardController="MTP__c" extensions="showCalender">
<apex:form >
<apex:pageBlock title="All Dtp">
<apex:pageblockTable value="{!mydtpList}" var="item">
<apex:column value="{!item.Name}"/>
<apex:column value="{!item.Date__c}"/>
<apex:column value="{!item.Visit_type__c}"/>
<apex:column value="{!item.Food_Expenses__c}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
=============================================
Controller
public class showCalender {
public List<DTP__c> mydtpList {set;get;}
public id tid{get;set;}
public showCalender(ApexPages.StandardController controller)
{
tid = ApexPages.currentPage().getParameters().get('id');
System.debug('***************dtp added*******************'+tid);
getMydtpList();
}
public List<DTP__c> getMydtpList(){
List<DTP__c> mydtpList =[select Name, Expenses__c, MTP__c, Food_Expenses__c, Date__c, Visit_type__c from DTP__c where MTP__c=:tid limit 50];
return mydtpList ;
}
//List<DTP__c> mydtpList = [select Expenses__c, Name, MTP__c, Food_Expenses__c, Visit_type__c from DTP__c where id=:tid];
}
Regards,
Satakshi
I am inserting some records when i click on custom button. Button is on parent object. I am creating child records of that parent object. I want to show all this records on visualforce page. I have written the code. But nothing is displaing. Can anyone please help me?
VF SHOWDTP
<apex:page standardController="MTP__c" extensions="showCalender">
<apex:form >
<apex:pageBlock title="All Dtp">
<apex:pageblockTable value="{!mydtpList}" var="item">
<apex:column value="{!item.Name}"/>
<apex:column value="{!item.Date__c}"/>
<apex:column value="{!item.Visit_type__c}"/>
<apex:column value="{!item.Food_Expenses__c}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
=============================================
Controller
public class showCalender {
public List<DTP__c> mydtpList {set;get;}
public id tid{get;set;}
public showCalender(ApexPages.StandardController controller)
{
tid = ApexPages.currentPage().getParameters().get('id');
System.debug('***************dtp added*******************'+tid);
getMydtpList();
}
public List<DTP__c> getMydtpList(){
List<DTP__c> mydtpList =[select Name, Expenses__c, MTP__c, Food_Expenses__c, Date__c, Visit_type__c from DTP__c where MTP__c=:tid limit 50];
return mydtpList ;
}
//List<DTP__c> mydtpList = [select Expenses__c, Name, MTP__c, Food_Expenses__c, Visit_type__c from DTP__c where id=:tid];
}
Regards,
Satakshi
update controller with this code.
All Answers
update controller with this code.
Your code is good just remove the "public List<DTP__c> mydtpList {set;get;}" line and " getMydtpList();" line from constructor.
Or you can compare your code with below code.
-Thanks
Ashlekh Gera
I have a similar situation, where the Master object is Contact and the Detail object is TargetX_SRMb__Financial_Aid__c. I want to display the data of the detail object on the Master object.
APEX CLASS:
public class FinAidData {
public id fid{get;set;}
public FinAidData(ApexPages.StandardController controller)
{
Contact con= (Contact)controller.getRecord();
if(con !=null)
fid = con.id;
}
public List<TargetX_SRMb__Financial_Aid__c> getFinaidList(){
List<TargetX_SRMb__Financial_Aid__c> finaidList = [Select Name, TargetX_SRMb__Amount__c,NYIT_Amount_Accepted__c,TargetX_SRMb__Accept_Date__c from TargetX_SRMb__Financial_Aid__c where TargetX_SRMb__Contact__c =: fid];
return finaidList;
}
}
VISUALFORCE PAGE:
<apex:page standardController="Contact" extensions="FinAidData">
<apex:form>
<apex:pageBlock title="Financial Aid Information">
<apex:pageBlockTable value="{!finaidList}" var="finaid">
<apex:column value="{!finaid.Name}"/>
<apex:column value="{!finaid.TargetX_SRMb__Amount__c}"/>
<apex:column value="{!finaid.NYIT_Amount_Accepted__c}"/>
<apex:column value="{!finaid.TargetX_SRMb__Accept_Date__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form >
</apex:page>
I am getting an error message when I try to save VF page and Apex Class. Please help me. I can't find the problem.
VF : Error: Unknown property 'ContactStandardController.finaidList'
APEX: Error: Compile Error: The method List<TargetX_SRMb__Financial_Aid__c> getfinaidresults() is referenced by Visualforce Page (Financial_Aid_Data) in salesforce.com. Remove the usage and try again. at line 13 column 45