Back to Devexpress

How to: Bind ASPxScheduler Appointment to ObjectDataSource

aspnet-15675-components-scheduler-examples-data-binding-how-to-bind-aspxscheduler-appointment-to-objectdatasource.md

latest4.6 KB
Original Source

How to: Bind ASPxScheduler Appointment to ObjectDataSource

  • Sep 02, 2025
  • 10 minutes to read

This document demonstrates how to implement an object data source for use with the ASPxScheduler control.

To create an Object Data Source for appointments and bind it to the ASPxScheduler instance, follow the instructions below.

Step 1. Create a Web Site

  1. Create a new Web Site in Visual Studio. In the File menu, click New , and then click Web Site. In the New Web Site dialog box that is invoked, click ASP.NET Empty Web Site.

  2. In the Website menu, click Add New Item. Select Web Form , leave the default name as is, and click Add.

  3. Switch to the Design View of the Default.aspx page, and drag the ASPxScheduler control from the DX.25.2: Scheduling Toolbox tab to the page.

Step 2. Create Classes for the Appointments Object Data Source

  1. In the Website menu, click Add ASP.NET Folder , and then click App_Code.

  2. In the Solution Explorer , right-click the App_Code folder, and then select New | Add New Item.

  3. In the Add New Item dialog box, select the Class template, specify its name as CustomEvents, and click Add. This class will contain all necessary properties for an appointment in the ASPxSchedulerStorage.Appointments collection. The property set is used in standard default mappings when the ASPxSchedulerStorage fetches data from the data source, or the appointment editing form posts data back to the storage.

  4. Create a collection of CustomEvent elements based on a generic System.ComponentModel.BindingList<T> class, which provides data binding.

  5. Provide methods for interaction with the ObjectDataSource control. The sole purpose of the CustomEventDataSource class is to provide an implementation of the insert, select, delete and update behaviors that will be called by the ObjectDataSource.

Step 3. Create an ObjectDataSource Control

  1. Switch to the page in which the ASPxScheduler control is located, and drag the ObjectDataSource control from the Data Toolbox tab to the page. Change the ID property of the control to appointmentDataSource.

  2. Click the smart tag of the control, and select the Configure Data Source item. In the Configure Data Source window, select CustomEventDataSource as the business object, and click Next.

  3. In the next panel, select the SelectMethodHandler method from the Choose a method drop-down list.

  4. Next, bind the ASPxScheduler to the ObjectDataSource control by setting its AppointmentDataSourceID property to appointmentDataSource in the Property window.

Step 4. Set Up the Appointment Mappings

  1. Next, set up mappings for the appointments fields. To do this, locate the < dx: ASPxScheduler > opening and closing tags in the Default.aspx file. Add the following code between them:

Step 5. Implement Methods Required for Proper Binding

  1. To set the appointment ID in the ASPxScheduler storage, create the ASPxScheduler1_AppointmentRowInserted method, which obtains the ID of the last inserted appointment from the object data source, and assigns it to the appointment in the ASPxScheduler storage. To populate the ObjectDataSource control with data, handle the System.Web.UI.WebControls.ObjectDataSource.ObjectCreated event, which is fired when the control is created:

  2. Switch to the Design View of the Default.aspx page, and select the ObjectDataSource component. Subscribe the ObjectCreated event to the appointmentsDataSource_ObjectCreated event handler.

  3. Select the ASPxScheduler component. Subscribe the AppointmentRowInserted event to the ASPxScheduler1_AppointmentRowInserted event handler.

Result

Run the project. Make sure that you can create, delete and edit appointments.