You need to sign in to do that
Don't have an account?
rao venky
Custom Controller
While run a following code i have got error like
[Error] Error: Mycontroller Compile Error: Illegal assignment from List<Account> to Account at line 6 column 3
Can anybody give a solution ?
CODE:
<apex:page controller="Mycontroller" tabStyle="Account">
<apex:form >
<apex:pageBlock title="Account Details">
<apex:pageBlockSection title="Account information">
<apex:inputField value="{!Account.Name}"/>
<apex:inputField value="{!account.Phone}"/>
<apex:inputField value="{!account.Industry}"/>
<apex:inputField value="{!account.Website}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Details">
<apex:inputField value="{!Account.Fax}"/>
<apex:inputField value="{!Account.Shippingcity}"/>
<apex:inputField value="{!Account.AnnualRevenue}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons>
<apex:commandButton action="{!Save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
CLASS:
public with sharing class Mycontroller
{
Public Account acc;
Public Mycontroller()
{
acc=[SELECT id,Name,Phone,Industry,Website,Fax,Shippingcity,AnnualRevenue from account Where id=:ApexPages.currentpage().getparameters().get('id')];
}
Public account getaccount()
{
return acc;
}
Public Pagereference Save()
{
update acc;
pagereference page=new Apexpages.StandardController(acc).view();
return Page;
}
}
[Error] Error: Mycontroller Compile Error: Illegal assignment from List<Account> to Account at line 6 column 3
Can anybody give a solution ?
CODE:
<apex:page controller="Mycontroller" tabStyle="Account">
<apex:form >
<apex:pageBlock title="Account Details">
<apex:pageBlockSection title="Account information">
<apex:inputField value="{!Account.Name}"/>
<apex:inputField value="{!account.Phone}"/>
<apex:inputField value="{!account.Industry}"/>
<apex:inputField value="{!account.Website}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Details">
<apex:inputField value="{!Account.Fax}"/>
<apex:inputField value="{!Account.Shippingcity}"/>
<apex:inputField value="{!Account.AnnualRevenue}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons>
<apex:commandButton action="{!Save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
CLASS:
public with sharing class Mycontroller
{
Public Account acc;
Public Mycontroller()
{
acc=[SELECT id,Name,Phone,Industry,Website,Fax,Shippingcity,AnnualRevenue from account Where id=:ApexPages.currentpage().getparameters().get('id')];
}
Public account getaccount()
{
return acc;
}
Public Pagereference Save()
{
update acc;
pagereference page=new Apexpages.StandardController(acc).view();
return Page;
}
}
Like this:
Hope that helps,
Clint
All Answers
Like this:
Hope that helps,
Clint
The code you have provided is working fine.. i did'nt get any errors.