

Part of the problem you're having is that in this scenario, you could have cases displayed from multiple accounts. The apex:relatedList tag is meant for displaying a single related list pertaining to a single parent record. You have a few options here though..
- You could iterate over the accounts, and display a related list for each account matching the target district.
- You could create a list view and use the <apex:enhancedList> component. The problem with this approach though, so that you can't adjust the list view based on the Target District... meaning you'd have to create a list view for each target district, which could get ugly quickly.
- You could role your own related list functionality in Visualforce, but it's more of an advanced level of development, so you'll likely spend a lot of time on it or you could find a consultant to do it for you.
The easiest of the three options in my opinion is Scenario 1, which would look like the following:
(Extension Controller)
(VF Page)public class TdCaseDisplay
{
public Set<Id> accountIds {get;set;}
public TdCaseDisplay(ApexPages.StandardController sc){
Id targetDistrictId = sc.getId();
Map<Id,Account> accounts = new Map<Id,Account>(
[Select Id From Account Where Target_District__c = :targetDistrictId]
);
accountIds = accounts.keySet();
}
}
In the code above, I changed your Apex class from a controller to an extension. An extension, well... extends standard controller functionality :) If you take a look at the constructor, it sets up a list of account ids, after querying accounts matching the target district. The query uses the awesome map SOQL syntax, which you may want to use elsewhere.Finally, the VF page repeats or iterates over that list of account ids, and then renders a related list of cases for each of the accounts.Hope that helps.<apex:page controller="Target_District__c" tabstyle="Case" extensions="TdCaseDisplay" >
<apex:detail relatedList="false" title="true"/>
<apex:repeat var="accountId" value="{!accountIds}">
Cases for Account {!accountId}
<apex:relatedList subject="{!accountId}" list="Cases" />
</apex:repeat>
</apex:page>