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
Sonam PatilSonam Patil 

System.NullPointerException: Argument cannot be null. Error in VF page

Hi,
Below is my code, I am getting the error as:
System.NullPointerException: Argument cannot be null.
Error is in expression '{!Del}' in component <apex:commandButton> in page task9_10: Class.acad.del: line 37, column 1
Class.acad.del: line 37, column 1

Code:
<apex:page standardController="Account" extensions="acad">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Add" action="{!add}" reRender="pb1"/>
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        
            <apex:pageBlock id="pb1">
            <apex:repeat value="{!lisin}" var="e1">
            
                <apex:panelGrid columns="5">
                    
                    <apex:panelGrid headerClass="name">
                        <apex:facet name="header">Del</apex:facet>
                        <apex:commandButton value="Delete" action="{!Del}"/>
                        <apex:param name="DeleteRow" assignTo="{!SelectedRowIndex}" value="{!e1.recCount}"/>
                    </apex:panelGrid>
                        
                        <apex:panelGrid title="SPD">
                            <apex:facet name="header">Country</apex:facet>
                            <apex:inputField value="{!e1.acc.ShippingCountry}"/>
                        </apex:panelGrid>
                        
                         <apex:panelGrid title="SPD">
                            <apex:facet name="header">Name</apex:facet>
                            <apex:inputField value="{!e1.acc.Name}"/>
                        </apex:panelGrid>
                    
                </apex:panelGrid>
            </apex:repeat>
            </apex:pageBlock>
    </apex:form>
</apex:page>


public with sharing class acad {

    List<Account> lisacc = new List<Account>();
   public List<innercls> lisin{get; set;}
    public String selectedRowIndex;
    public Integer count = 1;
    
    public acad(ApexPages.StandardController controller) {
    lisin = new List<innercls>();
    addmore();
   // selectedRowIndex=1;
    }
    
    public PageReference add(){
    addmore();
    count++;
    return null;
    }
    
    public PageReference Save(){
    PageReference pr = new PageReference('apex/Paginate2');
    for(Integer i=0;i<lisin.size();i++){
    lisacc.add(lisin[i].acc);
    }
    insert lisacc;
    pr.setRedirect(True);
    return pr;
    }
    
    public void addmore(){
    innercls objin = new innercls(count);
    lisin.add(objin);
    
    }
    
    public void del(){
    lisin.remove(Integer.valueof(selectedRowIndex)-1);
    count--;
    }
    
    public class innercls{
    public String recCount{get; set;}
    public Account acc{get;set;}
    
    public innercls(Integer stcount){
    reccount= String.valueof(stcount);
    acc=new Account();
    }
    }

}
sfdcMonkey.comsfdcMonkey.com
hi sonal
try this onces 
public String selectedRowIndex = '1' ;

in your controller code
Mark it best answer if it helps you
Thanks