I am using RadScheduler for showing/creating the Appointments in my Database.
My code is working fine (Create, Retrieve, Update, Delete) as long as I have non-recurring Appointments. But, as soon as a recurring type Appointment comes in account, everything stops working and I get following error on postback:
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.
What am I doing wrong here?
Following is my code, On .ASPX page:
And Code on .CS page:
I have found that doing EnableViewState="false" does the job, but I don't want to do that because then other functionalities like Rescource editing stops working correctly.
My code is working fine (Create, Retrieve, Update, Delete) as long as I have non-recurring Appointments. But, as soon as a recurring type Appointment comes in account, everything stops working and I get following error on postback:
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.
What am I doing wrong here?
Following is my code, On .ASPX page:
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server"> <telerik:RadScheduler ID="RadScheduler1" runat="server" TimeZoneOffset="00:00:00" AdvancedForm-EnableCustomAttributeEditing="true" SelectedView="MonthView" OverflowBehavior="Expand" StartInsertingInAdvancedForm="true" EnableViewState="true" DataKeyField="AppointmentID" DataStartField="CalendarStartDateTime" DataEndField="CalendarEndDateTime" DataSubjectField="AppointmentBody" DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="ParentAppointmentID" DataReminderField="Reminder" OnAppointmentCreated="RadScheduler1_AppointmentCreated" OnAppointmentInsert="RadScheduler1_AppointmentInsert" OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" OnAppointmentDelete="RadScheduler1_AppointmentDelete" OnRecurrenceExceptionCreated="RadScheduler1_RecurrenceExceptionCreated" OnReminderDismiss="RadScheduler1_ReminderDismiss" OnReminderSnooze="RadScheduler1_ReminderSnooze"> <AdvancedForm Modal="true"></AdvancedForm> <Reminders Enabled="true" MaxAge="5"></Reminders> <TimeSlotContextMenuSettings EnableDefault="true"></TimeSlotContextMenuSettings> <AppointmentContextMenuSettings EnableDefault="true"></AppointmentContextMenuSettings> </telerik:RadScheduler></asp:Content>And Code on .CS page:
protected void Page_Load(object sender, EventArgs e){ if (!IsPostBack) { BindAppointments(); }}private void BindAppointments(){ try { List<AppointmentEN> lstAppointment = AppointmentProvider.GetAppointments(); foreach (var item in lstAppointment) { item.RecurrenceRule = string.IsNullOrWhiteSpace(item.RecurrenceRule) ? null : item.RecurrenceRule; item.ParentAppointmentID = item.ParentAppointmentID == 0 ? null : item.ParentAppointmentID; } RadScheduler1.DataSource = lstAppointment; RadScheduler1.DataBind(); RadScheduler1.SelectedView = SchedulerViewType.MonthView; RadScheduler1.SelectedDate = DateTime.Now; //RadScheduler1.Visible = true; } catch (Exception ex) { }}I have found that doing EnableViewState="false" does the job, but I don't want to do that because then other functionalities like Rescource editing stops working correctly.
