Hi,
I have some code which displays timings in the allday row, specifically this one. My Code is:
With the context menu enabled, this is causing an exception when I switch week (in weekview). The exception is: "Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.", and it happens on:
You can find a sample code here.
Thank you for your support.
Daryl
I have some code which displays timings in the allday row, specifically this one. My Code is:
protected
void
radScheduler_TimeSlotCreated(
object
sender, TimeSlotCreatedEventArgs e)
{
// Calculate total hours per day.
if
(radScheduler.SelectedView == SchedulerViewType.WeekView && e.TimeSlot.Duration.TotalDays == 1)
{
double
totalHoursPerDay = 0;
double
totalOvertimeHoursPerDay = 0;
bool
weekend =
false
;
if
(e.TimeSlot.Start.DayOfWeek == DayOfWeek.Saturday || e.TimeSlot.Start.DayOfWeek == DayOfWeek.Sunday)
{
weekend =
true
;
}
foreach
(Appointment a
in
radScheduler.Appointments.GetAppointmentsInRange(e.TimeSlot.Start, e.TimeSlot.End))
{
// Check time of appointment and adding to hours or overtime accordingly.
if
(a.Start.TimeOfDay >=
new
TimeSpan(8, 0, 0) && a.End.TimeOfDay <=
new
TimeSpan(19, 0, 0) && weekend)
{
totalOvertimeHoursPerDay += a.Duration.TotalHours;
}
else
if
(a.Start.TimeOfDay >=
new
TimeSpan(8, 0, 0) && a.End.TimeOfDay <=
new
TimeSpan(17, 0, 0))
{
totalHoursPerDay += a.Duration.TotalHours;
}
else
if
(a.Start.TimeOfDay >
new
TimeSpan(17, 0, 0) && a.End.TimeOfDay <=
new
TimeSpan(19, 0, 0))
{
totalOvertimeHoursPerDay += a.Duration.TotalHours;
}
else
if
(a.Start.TimeOfDay >=
new
TimeSpan(8, 0, 0) && a.End.TimeOfDay <=
new
TimeSpan(19, 0, 0))
{
double
overtime = a.End.TimeOfDay.TotalHours - 17;
totalOvertimeHoursPerDay += overtime;
totalHoursPerDay += (a.Duration.TotalHours - overtime);
}
}
Literal hoursLiteral =
new
Literal();
Literal overtimeLiteral =
new
Literal();
if
(!weekend)
{
hoursLiteral.Text =
"Hrs: "
+ totalHoursPerDay.ToString();
}
overtimeLiteral.Text =
" O/T: "
+ totalOvertimeHoursPerDay.ToString();
radScheduler.Controls.Add(hoursLiteral);
radScheduler.Controls.Add(overtimeLiteral);
e.TimeSlot.Control.Controls.Add(hoursLiteral);
e.TimeSlot.Control.Controls.Add(overtimeLiteral);
}
}
With the context menu enabled, this is causing an exception when I switch week (in weekview). The exception is: "Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.", and it happens on:
radScheduler.Controls.Add(hoursLiteral);
You can find a sample code here.
Thank you for your support.
Daryl