+ Start a Discussion
Sankar GaneshSankar Ganesh 

List has no rows for assignment and Unknown property 'VisualforceArrayList.name' 

List has no rows for assignment
Everything works fine when I have values but if I have no values then this error occur while searching I came to know that I have to change object to list.If I change then this error occur 
Unknown property 'VisualforceArrayList.name' 
I give some part of my code
Visual force component:
// Visual force component

<apex:component controller="LongProjectOrderController" access="global" rendered="true">
  <apex:attribute description="lpo" name="lpo"  type="SalesOrder__c"/>
<table align="right">
<tr>
<td><b>Order No:</b></td>
<td>{!lpo.Name}</td>
</tr>
                           
<tr>
<td><b>Raised By:</b></td>
<td>{!lpo.CreatedBy.Name}</td>
</tr>
</table>

  <table>
 <tr>
<td><b>Summary of agreed Payment Schedule:</b></td>
<td><apex:outputText rendered="{!(ChildRecords.Room1_Payment_Include_In_Print__c == true)}" value="{!ChildRecords.PAYMENT_SCHEDULE_Room1__c}" /></td>
<td><apex:outputText rendered="{!(ChildRecords.Room2_Payment_Include_In_Print__c == true)}" value="{!ChildRecords.PAYMENT_SCHEDULE_Room2__c}" /></td>
</tr>
</table>

</apex:component>

controller
public with sharing class LongProjectOrderController {
public String MasterRecordId        {get; set;}
  
    public Project__c ChildRecords{get; set;}
   
    public LongProjectOrderController()
    {
     MasterRecordId =ApexPages.currentPage().getParameters().get('id');
   
      if(!String.isBlank(MasterRecordId)){
           
            
                 ChildRecords =
                [
                    SELECT Name,CreatedBy.Name,Room1_Payment_Include_In_Print__c,Room2_Payment_Include_In_Print__c
                       
                    FROM
                        Project__c
                    WHERE 
                        Long_Project_Order__c = :MasterRecordId
                ];
   
    }
}
}


 
SandhyaSandhya (Salesforce Developers) 
Hi,

Try to write getter and setter for your name property.

Please refer below link for the same.

http://salesforce.stackexchange.com/questions/49983/unknown-property-error
 
Hope this helps you!

If this helps you please mark it as solved.

Thanks and Regards
Sandhya
Sukesh Kumar 33Sukesh Kumar 33

Hi,
Try in the following way
 

public with sharing class LongProjectOrderController  {
    public String MasterRecordId        {  get; set;  }
  
    public Project__c ChildRecords   { get; set;   }
   
    public LongProjectOrderController() {
	
	 List<Project__c> lstProject = new List<Project__c>();
	 
         MasterRecordId =ApexPages.currentPage().getParameters().get('id');
	 
	  lstProject = [SELECT     Name,CreatedBy.Name,Room1_Payment_Include_In_Print__c,Room2_Payment_Include_In_Print__c
					 FROM Project__c
					WHERE Long_Project_Order__c = :MasterRecordId];
	 
	 ChildRecords = (!lstProject.isEmpty()) ? lstProject[0] : new Project__c();
    }
}