You need to sign in to do that
Don't have an account?
ethanone
Populate and retrieve values from visualforce picklist with custom object
I'm new to visualforce and I've got a custom object, Property__c with a multi-select picklist of classifications (Classification__c). How can I put those picklist values onto a visualforce page with a custom controller? And how do I retrieve the value(s) for use in a query?
<apex:page controller="YourCustomController">
<apex:form><apex:inputField value="{!prop.Classification}"/></apex:form></apex:page>
Controller:
public class YourCustomController{Property__c prop {get; set;}public YourCustomController(){this.prop = new Property__c();}}
You should think about using standard controller as well.
I believe your point is "multi-select picklist". If it is about a general field, Anand's post is the answer.
The value set by the user in a multi-select picklist field is stored as a string with "; (semi-colon)" separator like "A;B;C".
If you want to understand or to create the value in the controller by yourself, you can assume the format with ";" and parse or format your value (don't mess it up).
In query, there are special where-clause expression for multi-select picklist (e.g. includes, excludes). See following manual.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_querying_multiselect_picklists.htm
To query the multi-picklist field value, it's same as other field as a string.
ThomasTT
In the Custom Controller, you can create a apex selectlist.
On the page load, call the function which retrieves the values of that multi-picklist field. eg:
Schema.DescribeFieldResult fieldResult = Property__c.Classification__c.getDescribe();
List allValues = fieldResult.getPicklistValues();
Now, you can return the list of values to your VF page.