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
Pankaj Yadav 16Pankaj Yadav 16 

How to delete selected records and all records at a time in visual force page.

Please let me know the logic and appriciate your help.

Apex code:
public class ActiveAccAss2
{
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 10;
   
public ActiveAccAss2()
{
totalRecs = [select count() from account];
}
   
public List<account> getacclist()
{
List<account> acc = Database.Query('SELECT Name, website, AnnualRevenue, description, Type FROM account LIMIT :LimitSize OFFSET :OffsetSize');
System.debug('Values are ' + acc);
return acc;
}
   
public void FirstPage()
{
OffsetSize = 0;
}
   
public void previous()
{
OffsetSize = OffsetSize-LimitSize;
}
   
public void next()
{
OffsetSize = OffsetSize + LimitSize;
}public void LastPage()
{
OffsetSize = totalrecs-math.mod(totalRecs,LimitSize);
}
public boolean getprev()
{
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
}

Visual force code
<apex:page controller="ActiveAccAss2" >
<apex:form >
<apex:pageBlock id="details">
<apex:pageblockTable value="{!acclist}" var="acc">
    <apex:column >
    <apex:inputCheckbox />
    </apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.website}"/>
<apex:column value="{!acc.AnnualRevenue}"/>
<apex:column value="{!acc.Description}"/>
<apex:column value="{!acc.Type}"/>
</apex:pageblockTable>
<apex:pageblockButtons >
<apex:commandButton value="Activate/Inactivate"/>
<apex:commandButton value="Delete"/>
</apex:pageblockButtons>
   
<apex:pageblockButtons >
<apex:commandButton value="First Page" rerender="details" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
<apex:commandButton value="Last Page" rerender="details" action="{!LastPage}" disabled="{!nxt}"/>"
</apex:pageblockButtons>
</apex:pageBlock>
   
    </apex:form>
</apex:page>
Khan AnasKhan Anas (Salesforce Developers) 
Hi Pankaj,

I trust you are doing very well.

Below is the sample code to delete selected and all records, which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.

Custom Object : Course__c

Visualforce:
<apex:page controller="GroupDeleteController9">
    <apex:form >
        <apex:pageblock title="Search Course Detail Here">
            <apex:inputText value="{!key}"/>
            <apex:commandButton value="Search" action="{!search_now}"/>
            <apex:pageBlockTable value="{!sub}" var="c">
                <apex:column >
                    <apex:inputCheckbox value="{!c.check_box}" />
                </apex:column>
                <apex:column value="{!c.cs.Name}"/>
                <apex:column value="{!c.cs.Academic_Year__c}"/> 
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton id="deleteit" value="Delete Selected" action="{!delete_now}"/>
                <apex:commandButton id="deleteall" value="Delete All" action="{!delete_all}"/>
            </apex:pageBlockButtons>
        </apex:pageblock>
    </apex:form>
</apex:page>

Controller:
public class GroupDeleteController9 { 
    
    public List<WrapperClass> sub {get;set;}
    public String key {get;set;}
    public Boolean check_box {get;set;}
    public List<Course__c> del {get;set;}
    
    public GroupDeleteController9(){
        sub = new List<WrapperClass>();    
    }
    
    public PageReference search_now(){
        for(Course__c cr : [SELECT Name, Academic_Year__c FROM Course__c WHERE name LIKE :('%'+key+'%')]){
            sub.add(new WrapperClass (cr, false));
        }
        return null;
    }
    
    public PageReference delete_now(){
        del=new list<Course__c>();
        for(WrapperClass cc: sub){
            if(cc.check_box){
                del.add(cc.cs);
            }
        }
        delete del;   
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
    
    public PageReference delete_all(){
        del=new list<Course__c>();
        for(WrapperClass cc: sub){
            del.add(cc.cs);
        }
        delete del;   
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
    
    public class WrapperClass {
        public Course__c cs {get; set;}
        public Boolean check_box {get; set;}
        
        public WrapperClass(Course__c cs, Boolean check_box){
            this.cs = cs;
            this.check_box = check_box;
        }
    }
}


I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.

Thanks and Regards,
Khan Anas​
Raj VakatiRaj Vakati
Refer this links

http://www.infallibletechie.com/2014/08/deleting-checked-rows-using-apex-in.html
http://www.sandeeparora.org/2014/11/insert-delete-and-update-multiple-records-using-a-custom-controller-in-visualforce/
https://salesforce.stackexchange.com/questions/117058/how-to-delete-the-multiple-record-with-checkbox
https://developer.salesforce.com/page/Wrapper_Class
 
<apex:page controller="DeletingCheckedRowsController">
<apex:pagemessages />
    <apex:form >
        <apex:pageBlock id="pg">
           <apex:pageBlockTable value="{!listWrapper}" var="w">
               <apex:column > 
                   <apex:facet name="header">
                       <apex:inputCheckbox value="{!allBool}">
                           <apex:actionSupport reRender="pg" action="{!selectAll}" event="onchange"/>
                       </apex:inputCheckbox>
                   </apex:facet>
                   <apex:inputCheckbox value="{!w.checked}"/>
               </apex:column>
               <apex:column value="{!w.emp.Name}"/>
               <apex:column value="{!w.emp.Age__c}"/>
            </apex:pageBlockTable> 
            <apex:pageBlockButtons >
                <apex:commandButton value="Delete" action="{!del}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class DeletingCheckedRowsController {
    public List<WrapperClass> listWrapper {get;set;}
    public Boolean allBool {get;set;}
    
    public DeletingCheckedRowsController() {
        listWrapper = new List<WrapperClass>();
        List<Employee__c> listEmp = [SELECT Id, Name, Age__c FROM Employee__c];
        if(listEmp.size() > 0) {
            for(Employee__c emp : listEmp) {
                listWrapper.add(new WrapperClass(emp));
            }
        }
    }
    
    public class WrapperClass {
        public Boolean checked {get;set;}
        public Employee__c emp {get;set;}
        public WrapperClass(Employee__c emp) {
            this.emp = emp;
        }
    }
    
    public void del() {
        List<Employee__c> listEmpForDel = new List<Employee__c>();
        List<WrapperClass> listTempWrapper = new List<WrapperClass>();
        for(WrapperClass w : listWrapper) {
            if(w.checked) {
                listEmpForDel.add(w.emp);
            } else {
                listTempWrapper.add(w);
            }
        }
        if(listEmpForDel.size() > 0) {
            delete listEmpForDel;
            listWrapper = listTempWrapper;
        } else {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Select atleast one employee to delete'));
        }
    }
    
    public void selectAll() {
        if(allBool) {
            for(WrapperClass w : listWrapper) {
                w.checked = true;
            }
        } else {
            for(WrapperClass w : listWrapper) {
                w.checked = false;
            }
        }
    }
}

 
Pankaj Yadav 16Pankaj Yadav 16
the above code is work for Account ?? i have modified few thing still not working please help
public class wrapperClassController {
 public class GroupDeleteController9 {
   
    public List<WrapperClass> sub {get;set;}
    public String key {get;set;}
    public Boolean check_box {get;set;}
    public List<Account> del {get;set;}
   
    public GroupDeleteController9(){
        sub = new List<WrapperClass>();   
    }
   
    public PageReference search_now(){
        for(Course__c cr : [SELECT Name FROM Account WHERE name LIKE :('%'+key+'%')]){
            sub.add(new WrapperClass (cr, false));
        }
        return null;
    }
   
    public PageReference delete_now(){
        del=new list<Account>();
        for(WrapperClass cc: sub){
            if(cc.check_box){
                del.add(cc.cs);
            }
        }
        delete del;  
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
   
    public PageReference delete_all(){
        del=new list<Account>();
        for(WrapperClass cc: sub){
            del.add(cc.cs);
        }
        delete del;  
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
   
    public class WrapperClass {
        public Account cs {get; set;}
        public Boolean check_box {get; set;}
       
        public WrapperClass(Account cs, Boolean check_box){
            this.cs = cs;
            this.check_box = check_box;
        }
    }
}
}
Pankaj Yadav 16Pankaj Yadav 16
User-added image
error screen shot
Khan AnasKhan Anas (Salesforce Developers) 
Hi Pankaj,

Yes, you can use it with Account.

Visualforce:
<apex:page controller="GroupDeleteController9">
    <apex:form >
        <apex:pageblock title="Search Course Detail Here">
            <apex:inputText value="{!key}"/>
            <apex:commandButton value="Search" action="{!search_now}"/>
            <apex:pageBlockTable value="{!sub}" var="c">
                <apex:column >
                    <apex:inputCheckbox value="{!c.check_box}" />
                </apex:column>
                <apex:column value="{!c.cs.Name}"/>
                <apex:column value="{!c.cs.Phone}"/> 
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton id="deleteit" value="Delete Selected" action="{!delete_now}"/>
                <apex:commandButton id="deleteall" value="Delete All" action="{!delete_all}"/>
            </apex:pageBlockButtons>
        </apex:pageblock>
    </apex:form>
</apex:page>

Controller:
public class GroupDeleteController9 { 
    
    public List<WrapperClass> sub {get;set;}
    public String key {get;set;}
    public Boolean check_box {get;set;}
    public List<Account> del {get;set;}
    
    public GroupDeleteController9(){
        sub = new List<WrapperClass>();    
    }
    
    public PageReference search_now(){
        for(Account cr : [SELECT Name, Phone FROM Account WHERE Name LIKE :('%'+key+'%')]){
            sub.add(new WrapperClass (cr, false));
        }
        return null;
    }
    
    public PageReference delete_now(){
        del=new list<Account>();
        for(WrapperClass cc: sub){
            if(cc.check_box){
                del.add(cc.cs);
            }
        }
        delete del;   
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
    
    public PageReference delete_all(){
        del=new list<Account>();
        for(WrapperClass cc: sub){
            del.add(cc.cs);
        }
        delete del;   
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
    
    public class WrapperClass {
        public Account cs {get; set;}
        public Boolean check_box {get; set;}
        
        public WrapperClass(Account cs, Boolean check_box){
            this.cs = cs;
            this.check_box = check_box;
        }
    }
}

I hope it helps you.

Kindly mark this as solved if the information was helpful.

Thanks and Regards,
Khan Anas​
Pankaj Yadav 16Pankaj Yadav 16
getting unknown property wrapperclasscontrollerkey error
Khan AnasKhan Anas (Salesforce Developers) 
Pankaj,

Please check your code. You are using 2 classes.

public class wrapperClassController {
 public class GroupDeleteController9 {


Remove one class. After that, check the constructor name properly.
Pankaj Yadav 16Pankaj Yadav 16
how can i get the list instead of search button
 
Khan AnasKhan Anas (Salesforce Developers) 
Use below code:

Visualforce:
<apex:page controller="GroupDeleteController9">
    <apex:form >
        <apex:pageblock title="Search Course Detail Here">
            <apex:pageBlockTable value="{!sub}" var="c">
                <apex:column >
                    <apex:inputCheckbox value="{!c.check_box}" />
                </apex:column>
                <apex:column value="{!c.cs.Name}"/>
                <apex:column value="{!c.cs.Phone}"/> 
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton id="deleteit" value="Delete Selected" action="{!delete_now}"/>
                <apex:commandButton id="deleteall" value="Delete All" action="{!delete_all}"/>
            </apex:pageBlockButtons>
        </apex:pageblock>
    </apex:form>
</apex:page>

Controller:
public class GroupDeleteController9 { 
    
    public List<WrapperClass> sub {get;set;}
    public String key {get;set;}
    public Boolean check_box {get;set;}
    public List<Account> del {get;set;}
    
    public GroupDeleteController9(){
        sub = new List<WrapperClass>(); 
        for(Account cr : [SELECT Name, Phone FROM Account LIMIT 50]){
            sub.add(new WrapperClass (cr, false));
        }
    }
    
    public PageReference delete_now(){
        del=new list<Account>();
        for(WrapperClass cc: sub){
            if(cc.check_box){
                del.add(cc.cs);
            }
        }
        delete del;   
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
    
    public PageReference delete_all(){
        del=new list<Account>();
        for(WrapperClass cc: sub){
            del.add(cc.cs);
        }
        delete del;   
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
    
    public class WrapperClass {
        public Account cs {get; set;}
        public Boolean check_box {get; set;}
        
        public WrapperClass(Account cs, Boolean check_box){
            this.cs = cs;
            this.check_box = check_box;
        }
    }
}

I hope it helps you.

Kindly mark this as solved if the information was helpful.

Thanks and Regards,
Khan Anas​
Pankaj Yadav 16Pankaj Yadav 16
Thanks
Thanks
Thank you so much...!!

I have added above code in My final code.

error i am getting this error please - <apex:pageBlock> must be the direct parent of <apex:pageBlockButtons>


Visualforce code.
<apex:page controller="ActiveAccAss2" >
<apex:form >
<apex:pageBlock id="details">
<apex:pageblockTable value="{!acclist}" var="acc">
    <apex:column >
    <apex:inputCheckbox />
    </apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.website}"/>
<apex:column value="{!acc.AnnualRevenue}"/>
<apex:column value="{!acc.Description}"/>
<apex:column value="{!acc.Type}"/>
</apex:pageblockTable>
<apex:pageblockButtons >
<apex:pageBlockTable value="{!sub}" var="c">
                <apex:column >
                    <apex:inputCheckbox value="{!c.check_box}" />
                </apex:column>
                <apex:column value="{!c.cs.Name}"/>
                <apex:column value="{!c.cs.Phone}"/>
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton id="deleteit" value="Delete Selected" action="{!delete_now}"/>
                <apex:commandButton id="deleteall" value="Delete All" action="{!delete_all}"/>
</apex:pageBlockButtons>
   
   
<apex:commandButton value="Activate/Inactivate"/>
</apex:pageblockButtons>
       
<apex:pageblockButtons >
<apex:commandButton value="First Page" rerender="details" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
<apex:commandButton value="Last Page" rerender="details" action="{!LastPage}" disabled="{!nxt}"/>"
</apex:pageblockButtons>
</apex:pageBlock>
   
    </apex:form>
</apex:page>

Apex code.
 
public class ActiveAccAss2
{
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 10;
    
public ActiveAccAss2()
{
totalRecs = [select count() from account];
}
    
public List<account> getacclist()
{
List<account> acc = Database.Query('SELECT Name, website, AnnualRevenue, description, Type FROM account LIMIT :LimitSize OFFSET :OffsetSize');
System.debug('Values are ' + acc);
return acc;
}
    
public Account lastGoal {get; private set;}

  public void deleteLast()
    {
        delete lastGoal;
    }
    
   
public void FirstPage()
{
OffsetSize = 0;
}
    
public void previous()
{
OffsetSize = OffsetSize-LimitSize;
}
    
public void next()
{
OffsetSize = OffsetSize + LimitSize;
}public void LastPage()
{
OffsetSize = totalrecs-math.mod(totalRecs,LimitSize);
}
public boolean getprev()
{
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
    
    public List<WrapperClass> sub {get;set;}
    public String key {get;set;}
    public Boolean check_box {get;set;}
    public List<Account> del {get;set;}
    
     
    public PageReference delete_now(){
        del=new list<Account>();
        for(WrapperClass cc: sub){
            if(cc.check_box){
                del.add(cc.cs);
            }
        }
        delete del;   
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
    
    public PageReference delete_all(){
        del=new list<Account>();
        for(WrapperClass cc: sub){
            del.add(cc.cs);
        }
        delete del;   
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
    
    public class WrapperClass {
        public Account cs {get; set;}
        public Boolean check_box {get; set;}
        
        public WrapperClass(Account cs, Boolean check_box){
            this.cs = cs;
            this.check_box = check_box;
        }
    }
    
}

 
Khan AnasKhan Anas (Salesforce Developers) 
Pankaj,

You are using <apex:pageBlockButtons> at wrong place on line 14 in visualforce page. Refer below code:
 
<apex:page controller="ActiveAccAss2" >
    <apex:form >
        <apex:pageBlock id="details">
            <apex:pageblockTable value="{!acclist}" var="acc">
                <apex:column >
                    <apex:inputCheckbox />
                </apex:column>
                <apex:column value="{!acc.Name}"/>
                <apex:column value="{!acc.website}"/>
                <apex:column value="{!acc.AnnualRevenue}"/>
                <apex:column value="{!acc.Description}"/>
                <apex:column value="{!acc.Type}"/>
            </apex:pageblockTable>
            
            <apex:pageBlockTable value="{!sub}" var="c">
                <apex:column >
                    <apex:inputCheckbox value="{!c.check_box}" />
                </apex:column>
                <apex:column value="{!c.cs.Name}"/>
                <apex:column value="{!c.cs.Phone}"/>
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton id="deleteit" value="Delete Selected" action="{!delete_now}"/>
                <apex:commandButton id="deleteall" value="Delete All" action="{!delete_all}"/>
                
                <apex:commandButton value="Activate/Inactivate"/>
            </apex:pageBlockButtons>
            
            <apex:pageblockButtons >
                <apex:commandButton value="First Page" rerender="details" action="{!FirstPage}" disabled="{!prev}"/>
                <apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
                <apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
                <apex:commandButton value="Last Page" rerender="details" action="{!LastPage}" disabled="{!nxt}"/>"
            </apex:pageblockButtons>
        </apex:pageBlock>
        
    </apex:form>
</apex:page>

Regards,
Khan Anas
Pankaj Yadav 16Pankaj Yadav 16
When i tried to delete the record after slection i am getting below error.
User-added image


 
Pankaj Yadav 16Pankaj Yadav 16
Hi Khan, please help on this.
Khan AnasKhan Anas (Salesforce Developers) 
Hi Pankaj,

In the constructor, add below line of code:
 
sub = new List<WrapperClass>();

Like this:
public ActiveAccAss2()
{
sub = new List<WrapperClass>();
totalRecs = [select count() from account];
}

I hope it helps you.

Kindly mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Regards,
Khan Anas
Pankaj Yadav 16Pankaj Yadav 16
not getting error.

But unable to the records
 
<apex:page controller="ActiveAccAss2" >
    <apex:form >
        <apex:pageBlock id="details">
            <apex:pageblockTable value="{!acclist}" var="acc">
                <apex:column >
                    <apex:inputCheckbox />
                </apex:column>
                <apex:column value="{!acc.Name}"/>
                <apex:column value="{!acc.website}"/>
                <apex:column value="{!acc.AnnualRevenue}"/>
                <apex:column value="{!acc.Description}"/>
                <apex:column value="{!acc.Type}"/>
            </apex:pageblockTable>
            
            <apex:pageBlockTable value="{!sub}" var="c">
                <apex:column >
                    <apex:inputCheckbox value="{!c.check_box}" />
                </apex:column>
                <apex:column value="{!c.cs.Name}"/>
                <apex:column value="{!c.cs.Phone}"/>
            </apex:pageBlockTable>
            
            
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton id="deleteit" value="Delete Selected" action="{!delete_now}"/>
                <apex:commandButton id="deleteall" value="Delete All" action="{!delete_all}"/>
                
                <apex:commandButton value="Activate/Inactivate"/>
            </apex:pageBlockButtons>
            
            <apex:pageblockButtons >
                <apex:commandButton value="First Page" rerender="details" action="{!FirstPage}" disabled="{!prev}"/>
                <apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
                <apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
                <apex:commandButton value="Last Page" rerender="details" action="{!LastPage}" disabled="{!nxt}"/>"
            </apex:pageblockButtons>
        </apex:pageBlock>
        
    </apex:form>
</apex:page>
public class ActiveAccAss2
{
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 10;

    
public ActiveAccAss2()
{
sub = new List<WrapperClass>();
totalRecs = [select count() from account];
}
    
public List<account> getacclist()
{
List<account> acc = Database.Query('SELECT Name, website, AnnualRevenue, description, Type FROM account LIMIT :LimitSize OFFSET :OffsetSize');
System.debug('Values are ' + acc);
return acc;
}
    
public Account lastGoal {get; private set;}

  public void deleteLast()
    {
        delete lastGoal;
    }
    
   
public void FirstPage()
{
OffsetSize = 0;
}
    
public void previous()
{
OffsetSize = OffsetSize-LimitSize;
}
    
public void next()
{
OffsetSize = OffsetSize + LimitSize;
}public void LastPage()
{
OffsetSize = totalrecs-math.mod(totalRecs,LimitSize);
}
public boolean getprev()
{
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
    
    public List<WrapperClass> sub {get;set;}
    public String key {get;set;}
    public Boolean check_box {get;set;}
    public List<Account> del {get;set;}
      
    public PageReference delete_now(){
        del=new list<Account>();
        for(WrapperClass cc: sub){
            if(cc.check_box){
                del.add(cc.cs);
            }
        }
        delete del;   
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
    
    public PageReference delete_all(){
        del=new list<Account>();
        for(WrapperClass cc: sub){
            del.add(cc.cs);
        }
        delete del;   
        PageReference pr = new PageReference(System.currentPageReference().getURL());
        pr.setRedirect(true);
        return pr;
    }
    
    public class WrapperClass {
        public Account cs {get; set;}
        public Boolean check_box {get; set;}
        
        public WrapperClass(Account cs, Boolean check_box){
            this.cs = cs;
            this.check_box = check_box;
        }
    }
    
}


 
Pankaj Yadav 16Pankaj Yadav 16
delete the records from VF
Pankaj Yadav 16Pankaj Yadav 16
This is same request but different requirent i have created button for active and deactivate checkbox.
https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005oGFQAY