+ Start a Discussion
Sonam PatilSonam Patil 

Error: Wrapper Class

Below is the code of wrapper class of to display the Contacts of selected Accounts and also delete the selected Accounts.
It is displayind the contacts but Account is not getting deleted.
Can anyone help me to solve this problem?

<apex:page controller="charantest">
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Select" action="{!selected}"  />
            <apex:commandButton value="Delete" action="{!del}" reRender="pg"/>
            <apex:pageBlockTable value="{!ch}" var="ct">
                <apex:column headerValue="Select" >
                    <apex:inputCheckbox value="{!ct.isSelected}" />
                    <apex:column value="{!ct.act.Name}"/>
                    <apex:column value="{!ct.act.Industry}"/>
            <apex:pageBlockTable value="{!con}" var="c" id="pg">
                <apex:column value="{!c.lastName}"/>


public class charantest {

    public List<charnwrap> ch{get;set;}
    public List<ID> acc;
    public List<Contact> con{get;set;}
    public Charantest(){
        ch= new List<Charnwrap>();
        for(Account c:[Select id,name,industry from Account limit 5 offset 10]){
        ch.add(new charnwrap(c));
        public void selected(){
        acc= new List<Id>();
        for(charnwrap cw: ch){
    con=new List<contact>();
    con=[Select Id, lastName from Contact where AccountId=:acc];

 public PageReference del() {
    for(charnwrap wp:ch){
    Delete wp.act;
        return null;

    public class charnwrap{
        public Account act{get;set;}
        public boolean isSelected{get; set;}
        public charnwrap(Account a){