You need to sign in to do that
Don't have an account?
Urgent help: Constructor not defined
Hi All,
Getting the following error,can any one help if any idea ?
Error: Compile Error: Constructor not defined: [System.SelectOption].<Constructor>(Date, String) at line 15 column 29 |
Controller class:
public with sharing class CustomSettingsDemo_CLS{
public String selectedIso {get;set;}
public CustomSettingsDemo_CLS(ApexPages.StandardController controller) {
}
public List<selectOption> fqCodes {
get {
List<selectOption> options = new List<selectOption>();
for (FiscalQuarters__c fq : FiscalQuarters__c.getAll().values())
options.add(new SelectOption(fq.CustomFiscalQuarters__c,fq.Name+' - '+fq.CustomFiscalQuarters__c));
return options;
}
set;
}
}
Using custom setting in the controller class, any help is highly appreciated.
Thanks in advance,
rsk
This is because selectoptions require a string for each of the label and value. Thus you'll need to convert your date to a formatted string - if you convert the date to a date/time you can format it easily. Something like the following should do it.
All Answers
This is because selectoptions require a string for each of the label and value. Thus you'll need to convert your date to a formatted string - if you convert the date to a date/time you can format it easily. Something like the following should do it.
Hi Bob,
Thank you very much for your reply.
I'm struck how to use this in the selectoptions, it would be great if you can give how to use.
Best Regards,
Here's an example use of selectoption from my blog:
http://bobbuzzard.blogspot.co.uk/2012/08/preview-panel.html
Thank you very much Bob. I have converted date into String, which resolved the issue.
Best Regards,
rsk
Hi Bob,
I'm unable to save the date (in a date filed) as it converted into String. Is there any way to convert this into Date in VF ?, how can i save now.
Error:
Value '06-15-2012' cannot be converted from Text to Date.
I have used below code in my VF page.
<apex:selectList value="{!Opportunity.Quarter__c}" size="1">
<apex:selectOptions value="{!Items}"/>
</apex:selectList>
Any help is highly appreciated.
Best Regards,
rsk
You'll need to convert that to a date by breaking out the individual components and then instantiating a new date passing those as parameters.