This is a migrated thread and some comments may be shown as answers.

Problem with Desireliazation

4 Answers 109 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Georgi
Top achievements
Rank 1
Georgi asked on 20 Sep 2007, 03:42 PM
Hi guys.. it seems that the new version of your scheduler has some problems with the deserialization of the types when it postbacks. I will try to describe my scenario and the solution I found (after spending a LOT OF time of investigation).
1.I bind the radscheduler with List<MyClass> and set the datakeyfield = "ID" which is of type LONG.
2.Everything with the binding is OK ...I can see my appointments ;-)
3.I try to EDIT/DELETE/RESIZE some of the existing appointments.
4.Guess what happens ...error : Cannot find the appointment to delete in the Appointments collection.
[ArgumentException: Cannot find the appointment to delete in the Appointments collection.] Telerik.Web.UI.Scheduling.AppointmentController.DeleteAppointment(Appointment appointmentToDelete, Boolean deleteSeries) +1114 Telerik.Web.UI.RadScheduler.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +1062 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

When I examined what's returned back to me after the JSON serialization is a little different from what I expected.The JSON serializer converts the numbers of type long to int.

Then FindByID method of AppointmentCollection class returns null. The reason is in the following statement :
 if ((appointment.ID != null) && appointment.ID.Equals(id))
{ return appointment; }

the reason is that during the deserialization the original number (of type long) was converted to type int and the statement "appointment.ID.Equals(id)" always is false => the method returns null.
and then the exception is thrown.

4 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 21 Sep 2007, 02:49 PM
Hello Georgi,

Thank you for the heads up. We have fixed the problem by using a bit more robust serialization for the ID values that preserves their type.

Your Telerik points have been updated for your involvement.

Kind regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Georgi
Top achievements
Rank 1
answered on 22 Sep 2007, 08:24 PM
thanks for the quick response ...I hope this will save a lot of time for the devs in debugging  and searching for the problem.     
0
Irina
Top achievements
Rank 1
answered on 24 Sep 2007, 09:18 AM
Hi.
After getting the latest version I have the same error : Cannot find the appointment to delete in the Appointments collection. when I try to delete/update an appointment. I am using Guids for
DataKeyField. I noticed that for int is working fine.
With RadControls_Prometheus_2007_1_626_trial it was working fine for Guids too.
Before : Guid bookingId = new Guid(e.Appointment.ID);, where the Appointment.ID was a string. All ok.
Now the ID is an object and after converting :
Guid bookingId = new Guid(e.Appointment.ID.ToString());
the appointment is not found in the collection, so I get the error.

String was better, Guid is a value type and it doesn't work quite the same when the underlying type is "object".
0
T. Tsonev
Telerik team
answered on 27 Sep 2007, 05:19 AM
Hi Irina,

Initially, we also thought that string is going to be a better choice. Unfortunately, it does not work well when the underlying data-source relies on strong typing. This is the case with LinqDataSource and ObjectDataSource.

The real problem turned out to be the JSON serialization, as it is so lightweight that it does not correctly preserve the type. You do not have to worry about this, as we have already worked around that problem, by using different serialization for the identity values.

The fix is part of the Service Pack which is planned for release in mid-October.

Sincerely yours,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
Georgi
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Georgi
Top achievements
Rank 1
Irina
Top achievements
Rank 1
Share this question
or