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
Shifs SalheenShifs Salheen 

Custom Edit and View VF Page

I have created a custom VF list page which show all my campaigns in list view,now when I click on Edit button ,it should redirect me to a new VF page which is edit form with details filled.Please help me with this.

I have fetched the id and retrieved the record in Apex Controller,but how to bind it with VF page fields.

SandhyaSandhya (Salesforce Developers) 
Hi Shifs Salheen,

Please see below example code.


<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="/{!}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink>&nbsp;|&nbsp;
       <a href="javascript:if (window.confirm('Are you sure?')) DeleteAccount('{!row.Id}');" style="font-weight:bold">Del</a>
     <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:actionFunction action="{!DeleteAccount}" name="DeleteAccount" reRender="form" >
   <apex:param name="accountid" value="" assignTo="{!SelectedAccountId}"/>

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
   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) {
      // find the account record within the collection
      Account tobeDeleted = null;
      for(Account a : accs)
       if (a.Id == SelectedAccountId) {
          tobeDeleted = a;
      //if account record found delete it
      if (tobeDeleted != null) {
       Delete tobeDeleted;
      //refresh the data

Please find a screenshot of VFPage.

User-added image

Please accept my solution as Best Answer if my answer was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.

Thanks and Regards.
Shifs SalheenShifs Salheen
Thanks for the reply but in this case it opens standard edit page .I want to open Custom VF edit page.I have now achieved that.Only issue is it opens my VF page as well as standard edit  page