0

I have created a vf page on "Quote" object .Now i would like to get the fields of custom object "Student" API name as Student__c . This custom object does not have any relation ship with quote object .How to get the fields of this custom object in vf page .Written a wrapper class .But when i refer them the system throws an

Error: Unknown property 'QuoteContentController.wrapperclass.StudentDOB__c'

Any help is very much appreciated.

VF CODE :

<h2>Student</h2>
    <table class="bordered">
        <thead>
            <tr>
                <th class="header-table-heading">Studentname</th>
                <th class="header-table-heading">StudentDOB</th>
                <th class="header-table-heading">StudentSkills</th>
                <th class="header-table-heading">StudentLocation</th>
                <th class="header-table-heading">StudentResult</th>
            </tr>
        </thead>
        <tbody>
            <apex:repeat value="{!disp_list}" var="std">
            <tr>
                <td class="header-table-data"><apex:outputText value="{!std.name}"/></td>
                <td class="header-table-data"><apex:outputText value="{!std.StudentDOB__c}"/></td>
                <td class="header-table-data"><apex:outputField value="{!std.StudentSkills__c}"/></td>
                <td class="header-table-data"><apex:outputField value="{!std.StudentLocation__c}"/></td>
                <td class="header-table-data"><apex:outputField value="{!std.StudentResult__c}"/></td>
            </tr>
            </apex:repeat>
        </tbody>
    </table> 

Apex Class :

public with sharing class QuoteContentController {

    public QuoteContentController(ApexPages.StandardController controller) {

    }


public list<wrapperclass>disp_list{get;set;}

 //Declare a wrapper class  

public class wrapperclass{

public Student__c std1{get;set;}

public string Name{get;set;}

public Date StudentDOB{get;set;}

public string StudentSkills{get;set;}

public string StudentLocation{get;set;}

public Decimal StudentResult{get;set;} 

}

public QuoteContentController(){

//define constructor to instantiate the wrapper data type 

disp_list=new list<wrapperclass>();

 //Query all the list 
list<Quote> q =[select id , name from Quote where id = :ApexPages.CurrentPage().getparameters().get('id')];

list<Student__c> stdlist =[select id , name ,StudentDOB__c,StudentSkills__c,StudentLocation__c,StudentResult__c from Student__c where  createddate!=null order by name limit 1 ];

 //Iterate through each list to extract the values and add it to the custom wrapper data type  

  for (Quote qt :q){

    for(integer i=0;i<stdlist.size();i++){

wrapperclass w = new wrapperclass();

w.StudentDOB = stdlist[i].StudentDOB__c;

w.StudentSkills = stdlist[i].StudentSkills__c;

w.StudentLocation = stdlist[i].StudentLocation__c;

w.StudentResult = stdlist[i].StudentResult__c;

w.Name = stdlist[i].Name;

disp_list.add(w);
w.name =qt.name;
disp_list.add(w);
}
}
}
}
1

You are iterating through a wrapper class list in the VF page but accessing the fields as they are directly from the query results. When you iterating through the wrapper class list, you have to use that data structure in your VF markups. Use below format in your VF page.

<h2>Student</h2>
    <table class="bordered">
        <thead>
            <tr>
                <th class="header-table-heading">Studentname</th>
                <th class="header-table-heading">StudentDOB</th>
                <th class="header-table-heading">StudentSkills</th>
                <th class="header-table-heading">StudentLocation</th>
                <th class="header-table-heading">StudentResult</th>
            </tr>
        </thead>
        <tbody>
            <apex:repeat value="{!disp_list}" var="std">
            <tr>
                <td class="header-table-data"><apex:outputText value="{!std.name}"/></td>
                <td class="header-table-data"><apex:outputText value="{!std.StudentDOB}"/></td>
                <td class="header-table-data"><apex:outputField value="{!std.StudentSkills}"/></td>
                <td class="header-table-data"><apex:outputField value="{!std.StudentLocation}"/></td>
                <td class="header-table-data"><apex:outputField value="{!std.StudentResult}"/></td>
            </tr>
            </apex:repeat>
        </tbody>
    </table>
  • :since i dont which option to select as an BestAnswer.I have comment.If let me know the options surely i shall . – nikkey Dec 16 '14 at 11:41
  • Oh, the tick mark is for accepting an answer. Up arrow is for upvoting an answer if it's good for you. down arrow is for down voting if the answer is not good one. Take a look at here salesforce.stackexchange.com/tour – highfive Dec 16 '14 at 11:45
0

Please chk the names once. It is 'StudentDOB' in the wrapper class and you are trying to refer as 'StudentDOB__c' in the visual force page. The same applies for other wrapper class variables too.

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.