Deleting records:

In this scenario we used custom controller to perform delete action, and pageblocktable to display records and command link to delete individual records. In this we used ‘apex:param’ for transmitting individual record ids from vf to apex class.

Visualforce page:
<apex:page controller=”DeleteTestingNew” sidebar=”false”>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value=”{!records}” var=”r”>
<apex:column headerValue=”Action”>
<apex:commandlink value=”Delete” action=”{!doDelete}”>
<apex:param name=”rId” value=”{!r.Id}” assignTo=”{!rId}”/>
<apex:column headerValue=”Name”>
<apex:column headerValue=”city”>
<apex:column headerValue=”phone”>
<apex:column headerValue=”country”>

public with sharing class DeleteTestingNew {
public String rId{get;set;}
DataLoadTest__c delDlt = new DataLoadTest__c();
public PageReference doDelete() {
delDlt=[select Id from DataLoadTest__c where id =:rId];
delete delDlt;
pagereference ref=new pagereference(‘/apex/newdelete’);
return ref;
List<DataLoadTest__c> lstdlt = new List<DataLoadTest__c>();
public List<DataLoadTest__c> getRecords() {
lstdlt =[select id,name,city__c,country__c,phone__c from DataloadTest__c];
return lstdlt;