Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <apex:page controller="AddmultipleAccountController">
  2. <apex:form>
  3. <apex:pageBlock>
  4. <apex:pageBlockTable="{!ListAccount}" var="a" >
  5. <apex:inputField value="{!a.name}"/>
  6. <apex:inputField value="{!a.AccountNumber}"/>
  7. <apex:inputField value="{!a.Type}"/>
  8. <apex:inputField value="{!a.Industry}"/>
  9. </apex:pageBlockTable>
  10. <apex:pageBlockButtons>
  11. <apex:commandButton value="Add Accounts Row" action="{!addAccount}"/>
  12. <apex:commandButton value="Save Accounts" action="{!saveAccount}"/>
  13. </apex:pageBlockButtons>
  14. </apex:pageBlock>
  15. </apex:form>
  16. </apex:page
  17.  
  18. public class AddmultipleAccountController {
  19. public List<Account> ListAccount{get; set;}
  20.  
  21. public AddmultipleAccountController(ApexPages.StandardController myController)
  22.  
  23. {
  24. ListAccount = new List<Account>();
  25. Account acc= new Account();
  26. ListAccount.add(acc);
  27. }
  28.  
  29. public void addAccount()
  30. {
  31. Account acc= new Account();
  32. ListAccount.add(acc);
  33. }
  34.  
  35. public PageReference saveAccount()
  36. {
  37. for(integer i=0; i<ListAccount.size(); i++)
  38. {
  39. insert ListAccount;
  40. }
  41. return Page.AllAccountssaved;
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement