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
Galeeb SKGaleeb SK 

Deleting the Records using VF Pages

iam trying to delete the records using vf pages but can't delete.It not display any errors but no result.Tell me the suitable Answer

My code is
VF Page:
<apex:page standardController="contact" extensions="deletemultiplecont" recordSetVar="contacts" >
    <apex:form id="frm">
          <apex:pageblock id="pgblk">
           <table class="list " border="0" cellpadding="0" cellspacing="0">
           <tr class="headerRow" >
              <th class="headerRow"> Action </th>
              <th class="headerRow"> Name </th>
              <th class="headerRow"> MailingCity </th>
              <th class="headerRow"> Phone </th>
          <th> <apex:repeat value="{!contacts}" var="cont">
           <tr class="dataRow">
                <td class="dataCell"> <apex:commandlink value="delete" action="{!delmultplerec}" oncomplete="location.reload();">
                   <apex:param value="{!}" name="Id"/> 
                 </apex:commandLink> </td>
              <td class="dataCell"> <apex:outputText value="{!cont.Name}"/> </td>
              <td class="dataCell"> <apex:outputText value="{!cont.MailingCity}"/> </td>
              <td class="dataCell"> <apex:outputText value="{!}"/> </td>  
           </apex:repeat> </th>


Controller Class:

Public with sharing class deletemultiplecont
  public string Name{set;get;}
  public string Phone{get;set;}
  public string MailingCity{get;set;}
  public string asgn{get;set;}
  public contact cdel = new contact();
 public deletemultiplecont(apexpages.standardsetcontroller setcon)
  Public pagereference delmultplerec()
        Id contactId = apexpages.currentpage().getParameters().get('Id');
        system.debug('hidden val is..!!' +asgn);
            cdel = [select id from contact where id =: contactId];
            system.debug('delete rec is..!!' +cdel);
            delete cdel;            
            return NULL;
             catch(exception e)
                System.debug('The following exception has occurred: ' + e.getMessage());
                return NULL;

Galeeb SK
Arun Deepan LJArun Deepan LJ
You can use a wrapper class to add an check box button and in Apex , get all the id which is true and try deleting the contacts.