In this line,
String[] EventDates = [SELECT Id, EventDates__c FROM Event__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
You are trying to assign a list of custom objects, Event__c
, to a list of Strings. This is likely why you are getting the error. Normally, I would say you would want to try instead retrieving a list of Event__c objects, and looping through and assigning the EventDates__c field (assuming the field type is in fact, a string) to your list of strings. It looks like though this is a controller for a page where you pass the ID of the specific event object you want to work with, so you don't really have to worry about a list. I would change the whole class a bit so you are retrieving and assigning the Event object in the constructor and then you can access it in your method. Something like below
public with sharing class EventsPageController {
Event__c e {get; set;}
public String datesFromCalendar {get; set;}
public List<String> eachDt = new List<String>();
public void EventsPageController() {
e = [SELECT Id, EventDates__c,Event_Description__c,Event_Type__c,Maximum_Attendees__c,Occurrence__c,Program_Name__c FROM Event__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
}
public Event__c getEvent(){
return Event;
}
public String eventDates(){
String EventDates = e.EvenDates__c;
return EventDates;
}
}
If the EventDates__c field contains more than one date in the string and you are trying to seperate them and return them in a list of strings, this can be done using the join function, but this requires that you are using a separator in the field. Let's assume you are using a ';' as a separator. Then you could use something like this
public list<string> eventDates(){
list<String> EventDates = new list<String>();
EventDates = e.EventDates__c.split(';');
return EventDates;
}
You can obviously adjust this if you want to use a different seperator like a space or a comma.
Hope this helps.