function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jaba rajjaba raj 

Custom List Controller to retrive contact record using accountid

Hi,
i am trying to retrive all contact record for particular account using Custom List Controller but it showing
error:
Error: customlistcontrollerforaccountandcontact Compile Error: Incompatible types since an instance of LIST<SObject> is never an instance of LIST<Contact> at line 18 column 8

Vf page:
<apex:page controller="customlistcontrollerforaccountandcontact" >
 <apex:pageBlock >
     <apex:pageblockTable value="{!record}" var="a">
     <apex:column value="{!a.name}"/>
<apex:column value="{!a.phone}"/>
     
     
     </apex:pageblockTable>
 
 
 </apex:pageBlock>
</apex:page>

controller:
public class customlistcontrollerforaccountandcontact
{

Id id=apexpages.currentpage().getparameters().get('id');
public ApexPages.StandardSetController setCon {
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[select name,phone from contact where accountid=:id]));
}
return setCon;
}
set;
}
// Initialize setCon and return a list of records
public List<Contact> getrecord() {
return (List<Contact>) setCon.getRecords();
}
}


any help


Thanks in advance