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
Chanagan SakulteeraChanagan Sakulteera 

Help me please Why row didn't add.

Hi all, I'm new for the salesforce.
I want to know when i click the button will add a row but when i click nothing happen, row didn't add .

This is a code in visualforce page.
<apex:page standardController="Product_Service__c"  extensions="CostCalculation2Extention">
<apex:sectionHeader Title="Cost Calculation" subtitle="{!theProduct.Name}"/>
<apex:form >
    
    <apex:pageBlock title="Cost Calculator">
        <table border="1" cellspacing="0" style="border-color: #eeeeee;">
            <tr>
                <td style="background-color: #e0e3e5;" align="center"><b>No. of Pax</b></td>
                <td style="background-color: #e0e3e5;" align="center"><b>Total</b></td>
                <td style="background-color: #e0e3e5;" align="center" colspan="2"><b>A</b></td>
                <td style="background-color: #e0e3e5;" align="center"><b>B</b></td>
                <td style="background-color: #e0e3e5;" align="center" colspan="4"><b>C1</b></td>
                <td style="background-color: #e0e3e5;" align="center" colspan="4"><b>C2</b></td>
                <td style="background-color: #e0e3e5;" align="center" colspan="4"><b>C3</b></td>
                <td style="background-color: #e0e3e5;" align="center" colspan="4"><b>C4</b></td>
                <td style="background-color: #e0e3e5;" align="center" colspan="4"><b>C5</b></td>
                <td style="background-color: #e0e3e5;" align="center" colspan="4"><b>C5</b></td>
                <td style="background-color: #e0e3e5;" align="center" colspan="2"><b>E</b></td>
                <td style="background-color: #e0e3e5;" align="center" colspan="3"><b>G</b></td>
            </tr>
            <tr>
                <td align="center"><apex:commandButton value="Add Row" action="{!addRowA}" /></td>
                <td align="center"></td>
                <td align="center">International Flight</td>
                <td align="center">Domestic Flight</td>
                <td align="center"></td>
                <td align="center">C1.1</td>
                <td align="center">C1.2</td>
                <td align="center">C1.3</td>
                <td align="center">C1.4</td>
                <td align="center">C2.1</td>
                <td align="center">C2.2</td>
                <td align="center">C2.3</td>
                <td align="center">C2.4</td>
                <td align="center">C3.1</td>
                <td align="center">C3.2</td>
                <td align="center">C3.3</td>
                <td align="center">C3.4</td>
                <td align="center">C4.1</td>
                <td align="center">C4.2</td>
                <td align="center">C4.3</td>
                <td align="center">C4.4</td>
                <td align="center">C5.1</td>
                <td align="center">C5.2</td>
                <td align="center">C5.3</td>
                <td align="center">C5.4</td>
                <td align="center">C6.1</td>
                <td align="center">C6.2</td>
                <td align="center">C6.3</td>
                <td align="center">C6.4</td>
                <td align="center">E1.1</td>
                <td align="center">E2.2</td>
                <td align="center">Sales</td>
                <td align="center">Operation</td>
                <td align="center">Others</td>
            </tr>
            <apex:repeat value="{!rowPageA}" var="item" id="rowPage">
                <tr>
                    <td align="center"><apex:inputText id="number" value="{!num}"/></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                </tr>
            </apex:repeat>
        </table>
        <br/>
       
    </apex:pageBlock>

</apex:form>
</apex:page>

This is a code in controller.
public with sharing class CostCalculation2Extention{

    //-- Open Page --\\
    public Product__c theProduct {get; set;}
    private String productId {get; set;}
    public Product_Service__c[] lstProductService {get; set;}
    public Product_Service__c[] lstAddRowA {get; set;}
    //-- Open Page --\\
    
    //-- Attirbute --\\
    public List<Integer> rowPageA {get; set;}
    public List<Integer> rowPageB {get; set;}
    public List<Integer> num {get; set;}
    //-- Attirbute --\\
    
    //-- Constructor --\\
    public CostCalculation2Extention(ApexPages.StandardController controller) {
        productId = apexpages.currentpage().getparameters().get('CF00NO0000001EtuG_lkid');
        //system.debug('ProductId : ' + productId);
        theProduct = [select id, name from Product__c where id =: productId];
        //system.debug('The Product : ' + theProduct);
        lstProductService = [select id, name, Service__r.Name, Service__r.Id, Client_Expense_Adult__c, Client_Expense_Child__c, Tour_Leader_Expense__c, Local_Guide_Expense__c, Coach__c from Product_Service__c where Product__r.id =: theProduct.Id];
        //system.debug('List Product_Service : ' + lstProductService);
    }
    //-- Constructor --\\    
    
    //-- Add Row A --\\
    public void addRowA(){
        Integer numRow = 1;
        system.debug('numRow : ' + numRow);
        if(numRow == 1){
            system.debug('numRow : ' + numRow);
            rowPageA = new List<Integer>();
            for(integer i = 0 ; i < numRow ; i++){
                rowPageA.add(numRow);
                system.debug('row : ' + rowPageA.size());
                break;
            }
            numRow++;
            system.debug('numRow : ' + numRow);            
        }else{
            system.debug('numRow : ' + numRow);
            for(integer i = numRow ; i < (numRow+1) ; i++){
                rowPageA.add(numRow);
                break;
            }
            numRow++;
            system.debug('numRow : ' + numRow);
        }
    }
    //-- Add Row A --\\
}

This picture before click.
User-added image

This picture one time click.
User-added image

This picture two time click.
User-added image
Best Answer chosen by Chanagan Sakulteera

All Answers

Virendra ChouhanVirendra Chouhan
This was selected as the best answer
Chanagan SakulteeraChanagan Sakulteera
Thank Virendra Chouhan
I try you code but it not work.

And I received this error.
System.QueryException: List has more than 1 row for assignment to SObject 
Class.CostCalculation2Extention.<init>: line 23, column 1
Chanagan SakulteeraChanagan Sakulteera
Hey Virendra Chouhan,
I try it again and your link is help ful.

Thank you for your help ^_^.
Virendra ChouhanVirendra Chouhan
Remove this two lines :
 String sql = 'SELECT Name, E_Mail_Id__c FROM Member__c';
        memberList = Database.Query(sql);