ComponentOne Scheduler for ASP.NET: Working with Scheduler for ASP.NET AJAX > Data and Databinding > Binding C1Schedule to a Data Source

Binding C1Schedule to a Data Source

You can use standard ADO.NET databinding to bind C1Schedule to an existing database. First you must configure your data source. Then you can map tables in the database to the C1WebScheduleStorage to retrieve information from the desired columns of each table. You can load appointments, categories, contacts, labels, resources, and the status of appointments.

In this example, we will map the Appointments table of the Nwind.mdb database, which is installed by default with C1Schedule, to the Appointment Storage area of the C1WebScheduleStorage.

Configure the datasource

Complete the following steps to add and configure the datasource:

1.   Copy the Nwind.mdb file and paste it into your App_Data folder within your Web site project folder.

2.   Add a Microsoft AccessDataSource control to your Web application project.

3.   Select Configure Data Source from the AccessDataSource Tasks menu. You can access this by clicking the control's smart tag.

4.   Click the Browse button and select App_Data in the left pane of the Select Microsoft Access Database dialog box.

5.   Select Nwind.mdb in the right pane, click OK, and then click Next to continue through the wizard.

6.   In the Configure the Select Statement window, select Specify columns from a table or view and choose Appointments from the Name drop-down box.

7.   Check the following column boxes: Id, Body, End, Location, Start, Subject, and Properties. These are the fields we will map to in the C1WebScheduleStorage.

8.   Click Next.

9.   You can test the query and then click Finish.

Once the data source is configured, you can map to each of the columns in a table. You can do this through Visual Studio's Properties window.

Map the data source to the C1Schedule data storage

Complete the following steps to map the data source to the C1Schedule data storage:

1.   Add a C1Schedule control to your form.

2.   Select C1Schedule and expand the DataStorage node in the Properties window.

3.   Since you're binding C1Schedule to the data in the Appointments table, expand the AppointmentStorage node and set the DataSourceID property to AccessDataSource1.

4.   To map to the columns of the Appointments table, expand the Mappings node and enter the following column names in the MappingName properties for each mapping node:

 

Mapping Node

MappingName Property

AppointmentProperties

Properties

BodyMapping

Body

EndMapping

End

IdMapping

Id

IndexMapping

N/A

LocationMapping

Location

StartMapping

Start

SubjectMapping

Subject

 

The MappingName property corresponds with the name of the column in the database table.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.