You need to sign in to do that
Don't have an account?
dou
Dropdown list with a soql query
Hello !
I'm trying to create a dropdown based on a soql query :
my problem is that i get an error in my apex class : Constructor not defined: [System.SelectOption].<Constructor>(String)
and i don't understand how fix that error and make my dropdown working...
Thank you for your help ;)
I'm trying to create a dropdown based on a soql query :
public without sharing class ExtranetV2_TransfertsCommController2 { //some code public List<Commande__c> creneauHoraire = new List<Commande__c>(); public List<SelectOption> horaire { get{ creneauHoraire = [select Cr_neau_horaire_enl_vement__c from Commande__c]; horaire = new List<SelectOption>(); for(Commande__c ch : creneauHoraire){ horaire.add(new SelectOption(ch.Cr_neau_horaire_enl_vement__c)); } return horaire; } set; } public ExtranetV2_TransfertsCommController2(){ //some code } }here i call it in my visualforce page :
<apex:pageBlock> <apex:form> <apex:selectList size="1"> <label>Créneau horaire </label><apex:selectOptions value="{!horaire}"></apex:selectOptions> </apex:selectList> </apex:form> </apex:pageBlock>
my problem is that i get an error in my apex class : Constructor not defined: [System.SelectOption].<Constructor>(String)
and i don't understand how fix that error and make my dropdown working...
Thank you for your help ;)
All Answers
You can try below code and let me know if it works.
Best Regards,
-Vivek
Thank you it's working, and since i have try another method wich works too, I found help here for those who are getting trouble with the same thing : https://developer.salesforce.com/blogs/developer-relations/2008/12/using-the-metadata-api-to-retrieve-picklist-values.html