[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
   [Expand]Product Information
    Getting Started
   [Expand]Scheduler Elements
   [Expand]Visual Elements
   [Expand]Design-Time Features
    [Collapse]Data Binding
      How to: Bind an ASPxScheduler to MS SQL Server Database (Step-by-Step Guide)
      How to: Bind ASPxScheduler Appointment to ObjectDataSource
      How to: Filter Appointments
      How to: Bind an ASPxScheduler to XPO via the Unit of Work
      How to: Bind ASPxScheduler Resources to ObjectDataSource
    [Expand]Printing and Reporting
   [Expand]End-User Capabilities
   [Expand]Member Tables
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Bind ASPxScheduler Appointment to ObjectDataSource

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 theASPxScheduler instance, follow the instructions below.

Expanded 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.19.1: Scheduling Toolbox tab to the page.

Expanded 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 System.Web.UI.WebControls.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.

    This code snippet implements the object data source used for binding to the ASPxScheduler. Note that while other properties of a custom object are mapped in the application to regular appointment properties, the Price and ContactInfo fields should be mapped to appointment's PersistentObject.CustomFields.

Expanded 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.

    Switch to the other tabs, and specify the following methods: UpdateMethodHandler for the Update tab, InsertMethodHandler for the Insert tab, and DeleteMethodHandler for the Delete tab. Click Finish.

    The ObjectDataSource is now configured for the CustomEvent objects.

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

Expanded 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:

Expanded 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.

Expanded Result

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

Is this topic helpful?​​​​​​​