Skip to main content

How to: Create an Appointment for the Currently Selected Time Interval and Resource

  • 2 minutes to read

Make sure that the ASPxScheduler control is bound to data, and all mappings for the appointments and resources are correct. To learn how to bind the ASPxScheduler, refer to the following topics:

The code sample below demonstrates how to create a new appointment for the currently selected time interval. The SelectedInterval and SelectedResource properties allow you to access the selected time interval and resource. To add the newly created appointment to the ASPxScheduler, add the appointment to the Appointments collection of the scheduler’s Storage property.

using DevExpress.XtraScheduler;
using DevExpress.Web.ASPxScheduler;
// ...

// Create a new appointment
Appointment apt = new Appointment();

// Set the appointment's time interval to the currently selected time interval
apt.Start = ASPxScheduler1.SelectedInterval.Start;
apt.End = ASPxScheduler1.SelectedInterval.End;

// Set the appointment's resource to the resource that contains the currently selected time interval
apt.ResourceId = ASPxScheduler1.SelectedResource.Id;

// Add the new appointment to the appointment collection