function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gprasunagprasuna 

Row is automatically being added to the table when inserting a record

Hi,

 

I have created a visualforce page, In that i have created a table which has 16 columns and 1 row whose values are all dropdowns. Now after i select the values from the dropdowns and save the record, each time another row with all the dropdowns are being inserted into the table where i am inserting the values. I want only 1 row for the table.

Can anyone please help me out.

 

Thanks,

prasuna

VisualForceVisualForce

Hi..

I have modified TehNrd code here..

Sample code:

Controller Code: public class multiAccountInsert { public List<Account> accts {get; set;} public multiAccountInsert() { accts = new List<Account>(); accts.add(new Account()); } public void save() { insert accts; accts.clear(); accts.add(new Account()); } public PageReference save_close() { insert accts; PageReference home = new PageReference('/home/home.jsp'); home.setRedirect(true); return home; } } Page Code <apex:page controller="multiAccountInsert"> <apex:form > <apex:pageBlock > <apex:pageBlockButtons> <apex:commandButton value="Save and Close" action="{!save_close}" rerender="error"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!accts}" var="a" id="table"> <apex:facet name="footer"> <apex:commandLink value="Save" action="{!save}" rerender="table,error"/> </apex:facet> <apex:column headerValue="Name"> <apex:inputField value="{!a.Name}"/> </apex:column> <apex:column headerValue="Billing City"> <apex:inputField value="{!a.BillingCity}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

If u use cusotm drop down u have to use datamodel or wrapperclass.

 

More Details abt wrapper class : http://wiki.apexdevnet.com/index.php/Wrapper_Class

 I hope its help u..

gprasunagprasuna

Hi,

 

Thanks for your help, I will be trying this code.

 

Thanks,

prasuna