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

Object variable or With block variable not set

2 Answers 168 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Micke83
Top achievements
Rank 1
Micke83 asked on 04 Nov 2009, 08:27 AM
Hello,

I have some problems with the telerik scheduler. I get the following error message in a javascript alert box:
"Object variable or With block variable not set"

This is happening after adding an appointment. I have confirmed that what is triggering the error message is the DataItem("resurs_farg") on line 3 in this codebehind:

    Protected Sub RadScheduler1_AppointmentDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.SchedulerEventArgs) Handles RadScheduler1.AppointmentDataBound 
        Dim strFarg As String = "" 
        strFarg = e.Appointment.DataItem("resurs_farg").ToString() 
        e.Appointment.BackColor = System.Drawing.ColorTranslator.FromHtml(strFarg) 
        e.Appointment.BorderColor = Color.Black 
        e.Appointment.BorderWidth = Unit.Pixel(1) 
    End Sub 

I use this to put different colors on appointments belonging to dirrerent resources and it works great when i load the calendar but not when adding a new appointment. However, the appointent is added and it shows up after a reload.

All help is appreciated!

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar Milushev
Telerik team
answered on 06 Nov 2009, 04:54 PM
Hello Micke83,

This is because the DataItem is available when loading the appointment from the DataBase and not available when inserting a new appointment. If 'resurs_farg' is a Scheduler Resource you can get its value through the Apppontment.Resources collection in both cases.

Kind regards,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Micke83
Top achievements
Rank 1
answered on 19 Nov 2009, 10:41 AM
Thanks for your answer!

We solved this by using e.Appointment.Resources.GetResourceByType("Resurs").Key.ToString() instead. This didn't contain the value of the color but we could use it to look up the color in the database.
Tags
Scheduler
Asked by
Micke83
Top achievements
Rank 1
Answers by
Dimitar Milushev
Telerik team
Micke83
Top achievements
Rank 1
Share this question
or