[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Collapse]Scheduler
   [Expand]Product Information
    Getting Started
   [Expand]Scheduler Elements
   [Expand]Concepts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Collapse]Examples
    [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]Selection
    [Expand]Customization
    [Expand]Printing and Reporting
    [Expand]Miscellaneous
   [Expand]End-User Capabilities
   [Expand]Member Tables
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Gauges
  [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]Localization
 [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]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Bind an ASPxScheduler to XPO via the Unit of Work

This topic provides guidelines on binding the ASPxScheduler control to an XPO (eXpress Persistent Objects) data source using the UnitOfWork session class. The complete project you may download at How to bind ASPxScheduler to XPO via the Unit of Work - sample project.

Five steps are required to accomplish the task.

Expanded 1. Prepare the Data Sources

Define two persistent object classes - one for appointments, the other - for resources. Name them Task and Employee. The code is shown below:

Add two XPO data sources to your project by dragging them from the toolbox onto a form. Specify the IDs and XPObjectType.TypeName for these controls - the first will be the appointmentDataSource with the Task type assigned, the second will be the resourceDataSource with the Employee type assigned.

You may also find the Tutorial 5 - An ASP .NET Application for Data Editing document helpful, to learn how to use the XPO data source component.

Expanded 2. Specify the Mappings

Since the data source assignment is done at runtime via code, the mappings should be specified manually. Review the code below which illustrates this:

Expanded 3. Post Data Back to the Database

Handle the ASPxSchedulerDataWebControlBase.AppointmentsInserted, ASPxSchedulerDataWebControlBase.AppointmentsChanged and ASPxSchedulerDataWebControlBase.AppointmentsDeleted events to commit changes in the data source. Call the UnitOfWork.CommitChanges method of the Unit of Work object for this purpose.

Expanded 4. Provide the Correct Appointment Identifier

It is necessary to obtain a correct appointment identifier to track the newly created appointment. To accomplish this, a new XPORowInsertionProvider class is defined. It is aimed at retrieving the key identifier value of the last inserted appointment, and correct the corresponding value of the appointment in the storage. It handles the Session.ObjectSaved event of the Session object and the ASPxSchedulerDataWebControlBase.AppointmentsInserted event of the ASPxScheduler. The code for this class is presented below:

Expanded 5. Attach the Data Sources

Now you should set the ASPxSchedulerDataWebControlBase.AppointmentDataSource and ASPxSchedulerDataWebControlBase.ResourceDataSource values to the corresponding XPO data sources (appointmentDataSource and resourceDataSource) and call the ASPxWebControl.DataBind method to perform binding.

After completing these steps, run the project and observe the result - a web site with the ASPxScheduler control bound to an XPO data source. Note that you can connect XPO to a database server as described in the Connecting XPO to a Database Server (ASP.NET) article. By default, your data persists in the .mdb file of MS Access format within the App_Data folder.

Expanded See Also

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