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

Programmatically add appointments to RadScheduler

6 Answers 643 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Casey
Top achievements
Rank 1
Casey asked on 26 Nov 2012, 07:10 PM
Hello,

I'm trying to add an appointment to a RadScheduler in the code behind; however, I'm having no luck. I was hoping to create a new appointment, then use RadScheduler1.Appointments.Add(new Appointment(1, dt, dt, "Subject")); or something similar, but the .Add method isn't exposed and RadScheduler1.InsertAppointment(new Appointment(1, dt, dt, "Subject")); isn't working either.

If this is possible, please let me know which RadScheduler event I need to do this in.

Thanks!
Casey

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Nov 2012, 04:39 AM
Hi,

Here is the sample code that I tried to create appointment programmatically.
C#:
protected void Page_Load(object sender, EventArgs e)
{
        Appointment meetingAppointment = new Appointment();
        meetingAppointment.Subject = "Subject";
        meetingAppointment.Start = DateTime.Now;
        meetingAppointment.End = DateTime.Now;
        RadScheduler1.InsertAppointment(meetingAppointment);
}

Thanks,
Princy.
0
Casey
Top achievements
Rank 1
answered on 27 Nov 2012, 01:04 PM
Hi Princy,

I've tried using the InsertAppointment method already, but it doesn't work. Does it need to be done in a certain event (like a button click, or can it be done in the RadScheduler PreRender or other RadScheduler events)?  Does it matter that my RadScheduler doesn't allow and updates/deletes/inserts? It is just bound to a list of objects returned from a class library.

I'm in the middle of returning dummy data for the other dates I need to include appointments for, since creating a list of special dates and then creating appointments for each of those dates is not working.

Thanks!
Casey
0
Princy
Top achievements
Rank 2
answered on 28 Nov 2012, 06:29 AM
Hi Casey,

The AllowInsert property of RadScheduler checks whether it is possible to insert the appointments on double click of the timeslot. I was able to insert the appointments in the timeslot when AllowInsert property of RadScheduler is set to false. Here is the code snippet that I tried to create appointment programmatically for the specialdays in the RadScheduler.

ASPX:
<telerik:RadScheduler ID="RadScheduler1" runat="server" AllowInsert="false" ......... >
</telerik:RadScheduler>

C#:
private readonly DateTime[] SpecialDays = new DateTime[] { new DateTime(2012, 12, 1), new DateTime(2012, 12, 2) };
protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
{
    foreach (DateTime dt in SpecialDays)
    {
        if (DateTime.Compare(e.TimeSlot.Start.Date, dt) == 0)
        {
            Appointment meetingAppointment = new Appointment();
            meetingAppointment.Subject = "Subject";
            meetingAppointment.Start = dt;
            meetingAppointment.End = dt;
            RadScheduler1.InsertAppointment(meetingAppointment);
        }
    }
}

Hope this helps.

Regards,
Princy.
0
Kalpna
Top achievements
Rank 1
answered on 05 Aug 2013, 06:12 AM
Hello, will you please help me in radschedular. I am adding a resource type which datasourceid is sqldatasource id. i want to add multiple values in the resource type. i also want to save them comma separated in a table. i already set AllowMultipleValues property of resource type to true. but it does not take multiple values. on which event of radschedular i can do that. please help me..
0
Plamen
Telerik team
answered on 05 Aug 2013, 08:25 AM
Hi Kalpna,

 
You will have to use a provider in case of multiple valued resources in RadScheduler as it is described in this help topic and shown in this on-line demo.

Hope this will be helpful.

Regards,
Plamen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Bhavin
Top achievements
Rank 1
answered on 07 Aug 2013, 06:04 AM
Thanks a lot....Your post help me a lot....such a nice and helpful information...keep it up...Thanks Again.
Tags
Scheduler
Asked by
Casey
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Casey
Top achievements
Rank 1
Kalpna
Top achievements
Rank 1
Plamen
Telerik team
Bhavin
Top achievements
Rank 1
Share this question
or