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
sk kumarsk kumar 

showing error while writing code in visualforce pages..!!!

//Here my code logic is when i search the a perticualr account name in my account obj ..in reply i will gate the name & phone number of that perticular record.  but while running the code it  shows error like......:

 

Error: controller1 Compile Error: Illegal assignment from LIST<Account> to LIST<Account> at line 8 column 10

 

 

so anyone plz help me in this regard.....

                                                                                                                       .Thanx in advance..:)  //

 

 

//.........................................................................class..........................................................................................//

 

 

public with sharing class Controller

 {

      public string acName {get; set;}
       public List<Account> acc {get;set;}
        public List<Account> search()

      {
               acc= new list<Account>();
               acc=[select name, phone, rating from account where name =: acName];
                return null;
             }

}

 

 

//...............................................................visualforce page....................................................................................//

<apex:page controller="Controller2">
      <apex:form >
                 <apex:pageblock title="Account info">
                             Account Name: <apex:inputtext value="{!acName}"/>
                                    <apex:pageblockSection >
                                           <apex:commandButton value="Search" action="{!search}"/>
                                                  <apex:outputPanel >
                                                          <apex:pageblocktable value="{!acc}" var="a">
                                                           <apex:column value="{!a.Name}"/>
                                                      <apex:column value="{!a.phone}"/>
                                               </apex:pageblocktable>
                                          </apex:outputPanel>
                                 </apex:pageblockSection>
                        </apex:pageblock>
                  </apex:form>
</apex:page>

Best Answer chosen by Admin (Salesforce Developers) 
digamber.prasaddigamber.prasad

Hi,

 

Above controller class is saving correctly and same for page. However, name of controller you have given is "Controller", whereas in page you have set controller as "Controller2".

 

Correct it and let me know if it is still throwing error.

 

Happy to help you!

All Answers

digamber.prasaddigamber.prasad

Hi,

 

Above controller class is saving correctly and same for page. However, name of controller you have given is "Controller", whereas in page you have set controller as "Controller2".

 

Correct it and let me know if it is still throwing error.

 

Happy to help you!

This was selected as the best answer
digamber.prasaddigamber.prasad

Happy that it worked for you!

 

Could you please give me KUDOS if it helped you!