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

Apply EDIT/DELETE link to each record in pagetable.
Hi,
I wants to give EDIT/DELETE link to each record in pagetable. How can I do that?
I have tried it with picklist, like I took picklist to select the record and after selection value, applied the edit or delete button.
Thank you.
Amol Dixit
try this once
page:
<apex:page controller="DataTableEditRemoveController">
<apex:form id="form" >
<apex:pageBlock title="Accounts">
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockTable value="{!accs}" var="row">
<apex:column >
<apex:outputLink title="" value="/{!row.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink> |
<a href="javascript:if (window.confirm('Are you sure?')) DeleteAccount('{!row.Id}');" style="font-weight:bold">Del</a>
</apex:column>
<apex:column value="{!row.Name}"/>
<apex:column value="{!row.BillingStreet}"/>
<apex:column value="{!row.BillingCity}"/>
<apex:column value="{!row.BillingPostalCode}"/>
<apex:column value="{!row.BillingCountry}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:actionFunction action="{!DeleteAccount}" name="DeleteAccount" reRender="form" >
<apex:param name="accountid" value="" assignTo="{!SelectedAccountId}"/>
</apex:actionFunction>
</apex:form>
</apex:page>
class
public class DataTableEditRemoveController {
public List<Account> accs { get; set; }
//used to get a hold of the account record selected for deletion
public string SelectedAccountId { get; set; }
public DataTableEditRemoveController() {
//load account data into our DataTable
LoadData();
}
private void LoadData() {
accs = [Select id, name, BillingStreet, BillingCity, BillingPostalCode, BillingCountry from Account limit 20];
}
public void DeleteAccount()
{
// if for any reason we are missing the reference
if (SelectedAccountId == null) {
return;
}
// find the account record within the collection
Account tobeDeleted = null;
for(Account a : accs)
if (a.Id == SelectedAccountId) {
tobeDeleted = a;
break;
}
//if account record found delete it
if (tobeDeleted != null) {
Delete tobeDeleted;
}
//refresh the data
LoadData();
}
}
Visualforce Error
Help for this Page
The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.
"
DisplayTable.vfp
DataTableEditRemoveController.cls
Thanks in Advance!!!
CHANGE YOUR LINK DESCRIPTION & PASS THIS LINK ON THERE.
<a href="/apex/taskrecordview?delid={!abc.id}" style="font-weight:bold">Del</a>
CREATE THE VF PAGE THERE CRETE THIS METHOD PASS THE ID OF CURRENT FIELD
Id cid = (Id)ApexPages.currentPage().getParameters().get('delid');
if (cid != null)
{
Account acc1 = [select id from Account where id = :cid];
delete acc1;
}
Hi Here is the working code