+ Start a Discussion

VisualForce page with table

i am trying to get a custom object and its related items to show in a table in a visualforce page.  Currently i have the first object showing up but i am not sure how to pull in the related list


here is the controller

global with sharing class poistionController {
private Map<string,set<String>> employeeMap=new Map<string,set<String>>();

     public Employees__c pos{get;set;}

     public poistionController() {
        list<Training__C>trainList=[Select name from Training__C where employee__C=:employees__C.Name__c];
         pos = [select ID, Name, Active__C from Employees__c where Active__C= true];




and here is the page

<apex:page controller="poistionController" showHeader="false">
<apex:relatedList list="Training__C"/>
      <apex:pageblock title="test">
      <apex:dataTable value="{!pos}" var="Employee">
         <apex:column value="{!pos.name}">
         <apex:column value="{!pos.id}">



kevin Carotherskevin Carothers
I think what you need is a nested apex:repeat - given that you have what looks like two related objects.

Just taking a wild hack at your problem, see if this is sorta/kinda what you're looking for;

<apex:page controller="TrainingSearchController">
<apex:repeat value="{!employeeList}" var="key">
    <apex:outputText value="{!key.Name}" />
   <apex:repeat value="{!trainingMap[key]}" var="map">
       <Apex:outputText value="{!map.Name}"/> <br/>


public class TrainingSearchController {   
    public  List<Employee__c> employeList = [Select ID, Name FROM Employee__c];
    public  Map<Id,List<Training__c>> trainingMap = new Map<Id,List<Training__c>>();
    public TrainingSearchController(){  
          List<Id> theEids = new List<Id>();
          for(Employee__c e :employeList) {
              List<Training__c> l = new List<Training__c>();
              trainingMap.put(e.Id, l);
          for(Training__c  t:[Select Id, Name, Employee__r.Id From Training__c WHERE Employee__r.Id IN :theEids] ) {

   public Map<Id,List<Training__c>> gettrainingMap(){
        return trainingMap;

   public List<Employee__c> getemployeeList(){
        return employeList;

PS- There are much more eloquent ways to build maps of lists - this is just an example.

Plus - this solution might not at all match your problem -- because in the "typical" class/pupil problem, there is a many to many relationship -- multiple pupils can take multiple classes, and vice-versa.   If that is your case, you'll need to build a junction object to link the employees to your classes.