Recurring events not working in sharepoint calendarview webpart ExpandRecurrence

Hi,

I have implemented the sharepoint calendar webpart referring this 
post. I faced an error with recurring events, not working 
properly. It stretches for all the days , instead of displaying 
separately.

Reason:
why the recurring events not working properly in the calendar view ?
We are fetching the values from lists using query. In lists 
recurring events are just one list item instead of repeating for all 
the recurring days. So the query returns only one list item per 
recurring events

Solution:

I found the solution for this recurring events issue from this post.

Just change your query as below & assign the ExpandRecurrence as True


// Construct a query that expands recurring events
SPQuery query = new SPQuery();
query.ExpandRecurrence = true;
query.Query = "";

// Look forward from the beginning of the current month
query.CalendarDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

// Returns all items (including recurrence instances) that
// would appear in the calendar view for the current month
SPListItemCollection calendarItems = calendarList.GetItems(query);

Tats it.. Happy Coding

No comments:

Post a Comment

Keep ur coding aside.. Relax for some time..