Ok, issue with this code. But using a Scheduler instead of a Calendar...
protected void DayPilotScheduler1_BeforeEventRender(object sender, DayPilot.Web.Ui.Events.Scheduler.BeforeEventRenderEventArgs e)
string color = e.DataItem["color"] as string; // null exception here
e.DurationBarColor = color;
The above works fine on initial rendering. However, if you have a 'previous week' and 'next week' button which sets the StartDate the above event triggers and the DataItem field is null.
// example prev week button
protected void btnPrevWeek_Click(object sender, EventArgs e)
DayPilotScheduler1.StartDate = DayPilotScheduler1.StartDate.AddDays(-7);