You need to sign in to do that
Don't have an account?

hi , created a Account list , 1st record is not adding to the list
hi , created a list and going to add the record , but the 1st record is not getting added, only the second record is geting add, my i knw the reason behind that thanks ..
Controller:
my i know the reason, why iam not getting add, the 1st record, and other getting added,,
Thanks
Deepika
<apex:page controller="accountinsert" > <apex:form > <apex:pageblock > <apex:pageblockSection > <apex:inputField value="{!acc.name}"/> <apex:inputField value="{!acc.phone}"/> <apex:inputField value="{!acc.Rating}"/> <apex:inputField value="{!acc.Industry}"/> </apex:pageblockSection> <apex:pageblockButtons location="top"> <apex:commandButton Value="Submit" action="{!addtolist}" /> <apex:commandButton Value="Clear" action="{!Clear}" /> </apex:pageblockButtons> <apex:pageblockSection columns="1" Rendered="{!lstaccount.size>0}" > <apex:pageblockTable value="{!lstaccount}" var="a" > <apex:column headerValue="Name">{!a.name}</apex:column> <apex:column headerValue="Phone">{!a.Phone}</apex:column> <apex:column headerValue="Rating">{!a.Rating}</apex:column> <apex:column headerValue="industry">{!a.industry}</apex:column> </apex:pageblockTable> </apex:pageblockSection> </apex:pageblock> </apex:form> </apex:page>
Controller:
public class accountinsert { public list<account> lstaccount{get;set;} public account acc{get;set;} public accountinsert(){ lstaccount= new list<account>(); //acc = new account(); } public void addtolist(){ acc = new account(); lstaccount.add(acc); } public void Clear(){ lstaccount.clear(); } }
my i know the reason, why iam not getting add, the 1st record, and other getting added,,
Thanks
Deepika
Please use the below controller class:
Let me know if you still face any issues.
Thanks,
Abhishek Bansal.
All Answers
Please use the below controller class:
Let me know if you still face any issues.
Thanks,
Abhishek Bansal.
Thanks
Deepika