my apex code:
public class ListExample {
public list < account > myaccount {
get;
set;
}
public ListExample() {
account a1 = new account(name = 'sam', type = 'prospect');
account a2 = new account(name = 'ram', type = 'prospect');
myaccount = new list < account > ();
myaccount.add(a1);
myaccount.add(a2);
}
public pagereference save() {
update myaccount;
return null;
}
}
visualforce code:
<apex:page controller="ListExample">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!myaccount}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.type}"/>
</apex:pageBlockTable>
<apex:commandButton value="save" action="{!save}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
when i clicked save it shows this error: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] Error is in expression '{!save}' in component in page listexamplevf: Class.ListExample.save: line 17, column 1 what is the problem can anyone help me