You need to sign in to do that
Don't have an account?

Edit & Delete Command Buttons in Grid View
Hi,
Following is my Code of visualforce for Editing and Deleting a record from Grid iew display of records:
and controller class code is as follows:
but when I click Edit or Delete buttons for any record in the list view Nothing happens except that the page refreshes only.
How can I implement Edit and Delete of Records in Visualforce Page display records in Grid View structure?
Thanks.
Following is my Code of visualforce for Editing and Deleting a record from Grid iew display of records:
Code:
<apex:commandButton value="Edit" action="{!editContact}"> <apex:param name="editContact" value="{!c.Id}"></apex:param> </apex:commandButton> | <apex:commandButton value="Del" action="{!removeContact}" onclick="return confirm('Are you sure—');"> <apex:param name="delContact" value="{!c.Id}"></apex:param> </apex:commandButton>
and controller class code is as follows:
Code:
public PageReference removeContact() { cId = ApexPages.currentPage().getParameters().get('delContact'); Contact contact = Database.query('select Id from Contact where id='+cId); //Contact contact = [select Id from Contact where id=:cId]; delete contact; return null; } public PageReference editContact() { PageReference pageRef= new PageReference('/'+ApexPages.currentPage().getParameters().get('editContact')); pageRef.setredirect(true); return pageRef; }
but when I click Edit or Delete buttons for any record in the list view Nothing happens except that the page refreshes only.
How can I implement Edit and Delete of Records in Visualforce Page display records in Grid View structure?
Thanks.
This is my controller Code:
And here is the way I called Edit/Delete from APEX page:
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable var="a" value="{!acclst}" >
<apex:column headerValue="Delete" >
<apex:commandLink action="{!deleteacc}" onclick="if(!confirm('Are you sure?')) return false;" >
<apex:image value="http://free-121d5f44d20-121d603d1c5-121ee2b8103.force.com/img/func_icons/remove12.gif" width="15" height="15"/>
<apex:param value="{!a.Id}" name="deleteid" assignTo="{!recid}"/>
</apex:commandLink>
</apex:column>
<apex:column headerValue="Name" >
<apex:commandLink value="{!a.name}" action="/{!a.id}" target="blank"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
public with sharing class scrollupndown {
public string recid{get;set;}
public List<Order__c> acclst { get; set; }
public scrollupndown(){
acclst = [select name from Order__c];
}
public PageReference deleteacc() {
Order__c ac=[select id,name from Order__c where id=:recid];
delete ac;
pagereference ref =new pagereference('/apex/Buttontodelete');
ref.setredirect(true);
return ref;
}
}