1

This is my visual force page code,Event_Request__c is custom object, i want to list all EventName (EventName__c) on this visualforce page. i am using this code but i am not getting any value using this code. anyone please suggest me what am i doing wrong?

<apex:page docType="html-5.0"  standardController="Event_Request__c" >


 <apex:form >

        <apex:pageBlock title="Contact details for account" >

            <apex:pageBlockTable value="{!Event_Request__c}" var="con">

            <apex:column value="{!con.EventName__c}"/>



            </apex:pageBlockTable>

        </apex:pageBlock>

    </apex:form>
</apex:page>
2

If Event_Request__c is a custom object with field EventName__c (as per your note to @Martin.Kona) then to list all EventName__c you can't use a VF page on a single Event_Request__c as that will display only one event. Furthermore, the value= attribute on pageBlockTable has to take a list, not a single string

What you need is to use a standardSetController which you define on the VF page with a page attribute recordSetVar

<apex:page docType="html-5.0"  standardController="Event_Request__c" recordSetVar="EventRequests">

and then use {!EventRequests} as the value attribute in the pageBlockTable

<apex:pageBlockTable value="{!EventRequests}" var="con">

Now - all that said, standardSetControllers are a larger topic in and of themselves and it is worth reading VF in Practice, chapter 4 to learn about pagination, filters, and other bits. If you have issues, post a separate question once you get the basics working

2
  • Yes that was the problem, But after doing all this i am not getting all record in column. its returning only 21 record. it should be more that 100. any idea what should be done to get all record. – Salesfor_dev Feb 10 '16 at 20:33
  • yes - that is because by default, standardsetControllers return only 20 records; you need to read up on how to do pagination, filters, and possibly custom standardsetcontroller extensions. Do some research first and then post a new question if stuck – cropredy Feb 10 '16 at 20:39
0

You have to specify, what kind of relationship this Event_Request__c with EventName__c has. Typically, your code would look like this, if Event_Request__c had EventName__c as a childs.

<apex:pageBlock title="Contact details for account" >
  <apex:pageBlockTable value="{!Event_Request__c.EventName__c}" var="con">
     <apex:column value="{!con.Name}"/>
  </apex:pageBlockTable>
</apex:pageBlock>

Are you sure, that EventName__c isnt just a custom field? Please provide object model.

1
  • EventName__c is custom field in Event_Request__c object. and i tried what you told me to do but i am getting an error like Unknown property 'String.Name' – Salesfor_dev Feb 10 '16 at 19:35
0

In the above code given by Martin, use Event_Request__c.EventName__r instead of Event_Request__c.EventName__c. This will fetch you the Name of the Contact provided you pass the recordId as paramter in the url of your page.

https://URL/apex/PageName?id=recordId

1
  • it was the recordSetVar problem. i declared recordSetVar and its working now. – Salesfor_dev Feb 10 '16 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.