+ Start a Discussion
srutmsrutm 

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...

LakshmanLakshman

you can try doing as below:

 

Apex :

public Boolean showRecords{get;set;}
public List<CustomObject__c> cust {get;set;}
//In constructor
showRecords =false;
public void fetchRecords(){ cust = [Select Field1__c, Field2__c from CustomObject__c limit 1000];// you need to place a limit of 1000 as VF supports max of 1000 recors to be displayed
showRecords = true;
}

 

 

VFP:

<apex:pageblock>
<apex:commandButton value="List Records" action="{!fetchRecords}" rerender="pbTable"/> <apex:pageblocktable value="{!cust}" var="a" id="pbTable" rendered="{!showRecords}"> <apex:column value="{!a.Field1__c}"/> <apex:column value="{!a.Field2__c}"/> </apex:pageblocktable > </apex:pageblock>

 

Let me know if it works for you.

 

Regards,

Lakshman

 

 

Sai Sasidhar BhagavathulaSai Sasidhar Bhagavathula
Hi,

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);
    }
 }    

 
Deepali KulshresthaDeepali Kulshrestha
Hi Srutm,

- 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: -
-------------- Apex Controller------- -----
public class Records
{
    public List<Student__c> StudentRecords {get;set;}
    public void search()
        {
            StudentRecords = [SELECT Name,Email__c,Phone__c FROM Student__c LIMIT 100];
        }
}
----------------VF Page-------------------

<apex:page controller = "Records">
    <apex:form>
        <apex:pageBlock>
            <apex:commandButton value = "records" action = "{!search}"/>
                <apex:pageBlockTable value="{!StudentRecords}" var = "stu">
                    <apex:column value = "{!stu.Name}"/>
                    <apex:column value = "{!stu.Email__c}"/>
                    <apex:column value = "{!stu.Phone__c}"/>
                </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

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.
asif jamal 21asif jamal 21
How we can add edit functionlity in this type of list. someone plz help.