Log In
[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
  [Expand]Chart Control
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Rich Text Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Expand]File Management
  [Expand]Multi-Use Site Controls
   [Expand]Product Information
    Getting Started
   [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]HTML Editor
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Data Editors
  [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]Document Server
[Expand]Report Server
[Expand]eXpressApp Framework
[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 ASPxScheduler.AppointmentsInserted, ASPxScheduler.AppointmentsChanged and ASPxScheduler.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 ASPxScheduler.AppointmentsInserted event of the ASPxScheduler. The code for this class is presented below:

Expanded 5. Attach the Data Sources

Now you should set the ASPxScheduler.AppointmentDataSource and ASPxScheduler.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?​​​​​​​