0

I have a custom object(survey__c) and custom field which holds the picklists values of the month (month__c). i want to use these picklist values in vf page.... i am using a custom controller in vf page .....can anyone help in resolving this issue with an example .

vf page :

<apex:selectList id="Months" value="{!Survey__c.Month__c}" size="1" required="true">
    <apex:selectOptions value="{!months}"/>        
</apex:selectList> 
<p/>

controller :

public List<SelectOption> getMonths()

{

  List<SelectOption> options = new List<SelectOption>();



   Schema.DescribeFieldResult fieldResult =  Survey__c.Month__c.getDescribe();

   List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();



   for( Schema.PicklistEntry f : ple)

   {

      options.add(new SelectOption(f.getLabel(), f.getValue()));

   }       

   return options;

}

it is giving error as -

Unknown property : 'CommunitySurveyContrller.Survey__c'

5
  • post your controller code and vf page. it's hard to guess what's causing your error Commented Sep 23, 2015 at 4:53
  • edited the code Commented Sep 23, 2015 at 4:55
  • are you using standardcontroller? Commented Sep 23, 2015 at 4:55
  • i am using a custom controller "CommunitySurveyContrller" Commented Sep 23, 2015 at 4:56
  • I think there is not variable defined (with get;set;) as Survey__c, which of-course you cannot define because identifiers cannot contain __. So I think your binding property is incorrect. You need to define a variable in your code and bind the selectlist to that Commented Sep 23, 2015 at 4:57

1 Answer 1

0

Assuming Survey__c is what you are trying to populate, you need to define a variable/property in your controller, i.e.:

public Survey__c survey {get; set;}

then in your constructor, instantiate it, i.e.:

public CommunitySurveyContrller() { survey = new Survey__c(); }

then in your VF page, access/connect it, i.e.:

<apex:selectList id="Months" value="{!survey.Month__c}" size="1" required="true"> <apex:selectOptions value="{!months}"/> </apex:selectList>

hope this helps.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.