+ Start a Discussion
Lukesh KarmoreLukesh Karmore 

Vf page is not updating account

i am new to visualforce i created a page with customController that shows list of account and i want to update account  field within the list below is my code ,so any one please let me know where is the mistake
its not updating field

public class CustomController {
    list<account> acts;
    public list<account> getacts(){
        acts=new list<account>();
       acts=[select name,rating,industry,type from account where rating!=null AND type!=null limit 20];
        return acts;
    public pageReference save(){
        update acts;
        return null;

<apex:page  Controller="CustomController">
 <apex:form >
 <apex:pageBlock title="Account Display">
     <apex:pageBlockButtons location="bottom">
     <apex:commandButton value="save" action="{!save}"/>
     <apex:pageMessages />
 <apex:pageBlockSection >
 <apex:pageBlockTable value="{!acts}" var="c">
 <apex:column value="{!c.name}"/>
 <apex:column value="{!c.rating}"/>
 <apex:column value="{!c.Industry}"/>
 <apex:column value="{!c.type}"/>
     <apex:inlineEditSupport />
Thank You
ANUTEJANUTEJ (Salesforce Developers) 
Hi Lukesh,

>> https://developer.salesforce.com/forums/?id=9060G0000005eLUQAY

The above link has an implementation to update an account record via visualforce page, below is the controller class that is mentioned you can modify it to fit your need.
public class OppAccupdateController 
    public Account Acc {get;set;}
    public Opportunity Opp;
    public string errormessage {get;set;}
    public OppAccupdateController(Apexpages.StandardController controller)
        opp = (Opportunity)controller.getRecord();
        ID accid = [select AccountID from Opportunity where ID=:opp.Id].AccountID;
        acc = [select id,Website, Project_Manager__c, Account_Director__c, Account_Manager__c from account where ID=:accid]; // specify the list of fields after type seperated by comma from account that you have used in VF page 
    public void Accsave()
        update acc;
        }catch(Exception e)
        system.debug('exception'+' '+ e.getMessage());
        errormessage = e.getMessage();

Let me know if it helps you and close your query by marking it as the best answer so that it can help others in the future.  

Lukesh KarmoreLukesh Karmore
No not helpful , I want to know where  is the error in my code it helps me to improve