You need to sign in to do that
Don't have an account?
srutm
display list of all records of my custom object in visual force page
I have my custom object,with records,i need all my records to be displayed in my visual force page... when i click on button listrecords...
you can try doing as below:
Apex :
VFP:
Let me know if it works for you.
Regards,
Lakshman
I am trying to diplay the records in VF Page as is shown above, but unable to fetch records from SOQL.
Could you please help me out.
Thank you in Advance !
public class CustomControllerView {
public List<Test__c> test{set;get;}
public void ControllerView(){
test = new List<Test__c>();
test = [SELECT Id,Name,TestPhone__c FROM Test__c LIMIT 10];
system.debug('@@@' + test);
}
}
- I read your problem and implemented it in my Org and it is working fine.
- Please use the below code and customize as per your need: -
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.
Visualforce Page (EditRecordsPage (http://salesforce.com/trailblazer/prahladbandhu)):
<apex:page controller="EditRecordsController">
<apex:form>
<apex:pageBlock title="Edit Records">
<apex:pageBlockTable value="{!records}" var="record">
<apex:column headerValue="Name">
{!record.Name}
</apex:column>
<!-- Add more columns for other fields as needed -->
<apex:column>
<apex:commandButton value="Edit" action="{!editRecord}">
<apex:param name="recordId" value="{!record.Id}" assignTo="{!recordId}" />
</apex:commandButton>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
EditRecordsController
public with sharing class EditRecordsController {
public CustomObject__c record { get; set; }
public String recordId { get; set; }
public EditRecordsController() {
record = [SELECT Id, Name /* Add other fields */ FROM CustomObject__c WHERE Id = :recordId LIMIT 1];
}
public PageReference editRecord() {
PageReference editPage = Page.EditRecordPage;
editPage.getParameters().put('recordId', recordId);
return editPage;
}
}
EditRecordPage
<apex:page controller="EditRecordController">
<apex:form>
<apex:pageBlock title="Edit Record">
<apex:pageBlockSection columns="1">
<apex:inputField value="{!record.Name}" label="Name" />
<!-- Add more fields for other record details as needed -->
</apex:pageBlockSection>
</apex:pageBlock>
<apex:commandButton value="Save" action="{!saveRecord}" />
</apex:form>
</apex:page>
EditRecordController (https://salesforce.com/trailblazer/prahladbandhu)
public with sharing class EditRecordController {
public CustomObject__c record { get; set; }
public String recordId { get; set; }
public EditRecordController() {
record = [SELECT Id, Name /* Add other fields */ FROM CustomObject__c WHERE Id = :recordId LIMIT 1];
}
public PageReference saveRecord() {
update record;
PageReference listPage = Page.EditRecordsPage;
return listPage.setRedirect(true);
}
}
Thanks
Prahlad Bandhu (https://salesforce.com/trailblazer/prahladbandhu)