Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[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
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [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
  [Collapse]Scheduler
   [Expand]Product Information
    Getting Started
   [Expand]Fundamentals
   [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 to ObjectDataSource
      How to: Filter Appointments
      How to: Bind an ASPxScheduler to XPO via the Unit of Work
      How To: Add Resources to ASPxScheduler Bound to ObjectDataSource
    [Expand]Selection
    [Expand]Customization
    [Expand]Printing and Reporting
    [Expand]Miscellaneous
   [Expand]End-User Capabilities
   [Expand]Member Tables
  [Expand]HTML Editor
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gauges
  [Expand]Data Editors
  [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]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How To: Add Resources to ASPxScheduler Bound to ObjectDataSource

This document demonstrates how to add Resources to the ASPxScheduler control. There are two methods to achieve this. The simplest one is to create a Resource object instance and add it directly to the ASPxResourceStorage. This method, however, has a disadvantage - you will need to use the DataBind method of the ASPxScheduler to create a new resource collection from the resource data source after the application is initialized. Thus, the performance of your application will suffer from additional data requests. The preferred method is to implement another ObjectDataSource component for resources in the same manner as it was done for appointments in the previous How to: Bind ASPxScheduler to ObjectDataSource topic.

The steps to implement this component are as follows.

Expanded Step 1. Create a Class to Store Resource Data

  1. Open the project containing the ASPxScheduler and the Appointments object data source, which was created in the previous How to: Bind ASPxScheduler to ObjectDataSource topic.
  2. In the App_Code folder, create a new Class template, and name it CustomResource.
  3. Define the class that will contain the necessary properties for the resources in the ASPxSchedulerStorage.Resources. The minimum requirement is to provide a unique identifier and a caption value (the name of the resource).
  4. Create a list of CustomResource elements, and implement a method for the Select operation.
  5. Show Me

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4849.

  6. To associate an appointment with a resource, modify the CustomEvent class in the following way. Create a resourceID field of the Object type and implement the ResourceID property.

Expanded Step 2. Create a Resources Object Data Source

  1. Switch to the Design View of the Default.aspx page, and drag the ObjectDataSource control from the Data Toolbox window to the page. Change the ID property of the control to resourceDataSource.
  2. Click the control's smart tag, and click the Configure Data Source item.

  3. In the Configure Data Source window, select CustomResourceDataSource as the business object. Click Next.

  4. In the next panel, select the SelectMethodHandler method from the Choose a method drop-down list. Leave the methods in the other tabs empty, since they are not required, and not implemented in the CustomResourceDataSource class.

  5. Next, bind the ASPxScheduler to the ObjectDataSource control by setting its ResourceDataSourceID property to resourceDataSource in the Property window.

Expanded Step 3. Set Up the Resource Mappings

Next, set up the mapping for the Resource field in the ASPxSchedulerStorage. To do this, locate the < dx: ASPxScheduler > opening and closing tags in the Default.aspx file. Correct your code so that it resembles the following.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4849.

Expanded Step 4. Create a class to fill the Resources Data Source

  1. In the App_Code folder, create a new Class template, and name it ResourceHelper. The FillObjectDataSourceWithResources method demonstrates how to use an array of strings to populate the Resources data source.
  2. Show Me

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4849.

  3. To group your appointments in the scheduler by resource, set the ASPxScheduler.GroupType property to Resource in the Property window.

Expanded Step 5. Implement methods for data binding

In the Default.aspx code file, add the ObjectDataSource's ObjectCreated event handler, which will create an instance of the custom data source (CustomResourceDataSource), and initialize it with the CustomResourceList object.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4849.

Expanded Result.

Run the project. The image below shows the scheduler at runtime.

How would you rate this topic?​​​​​​​