0

I am beginner to salesforce. I want to add row dynamically to VF page when i clicked add row button.

this is my script

<apex:page standardController="Employee__c"  extensions="Cutomextension">
   <apex:form >
      <apex:pageBlock >
         <apex:pageBlockTable value="{!Employee__c}" var="emp">
            <apex:column headerValue=" Employee Name">
               <apex:inputField value="{!emp.name}"/>
            </apex:column>
         </apex:pageBlockTable>
         <apex:commandButton action="{!add}" value="Add Row"/>
      </apex:pageBlock>
   </apex:form>
</apex:page>

Controller:

public with sharing class Cutomextension {

    public Employee__c emp {get; set;}
    public List<Employee__c> empList {get; set;}
    public static Integer addCount {get; set;}

    public Cutomextension(ApexPages.StandardController controller) {
        this.emp = (Employee__c)Controller.getRecord();
        empList = new List<employee__c>();
    }

    public void add() {
        empList.add(new employee__c());
    }
}

When i clicked add row button, new row doesn't get added. Can anyone tell me what is wrong with my code.

1

As I understand you want to show a list of records in your page. Please read the following articles about showing a set of records in a pages and try to code it for your case.

  • I checkd with all the functionality but its not working.Is I need to use wrapper class here??? – Mubarakkk Feb 18 '15 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.