DayPilot Knowledge Base

AJAX Calendar/Scheduling Controls
DayPilot Pro (AJAX Calendar Control)
» DayPilot ASP.NET Calendar
DayPilot Pro (AJAX Monthly Calendar Control)
» DayPilot ASP.NET Monthly Calendar
DayPilot Pro (AJAX Scheduler Control)
» DayPilot ASP.NET Scheduler
DayPilot » Knowledge Base » How to use DayPilot Scheduler with LINQ to SQL

How to use DayPilot Scheduler with LINQ to SQL

Last revision: Mar 17, 2010

This is a quick example of using LINQ to SQL with DayPilot Scheduler.

1. Prerequisites

2. Create a new DBML file

Create a new DBML file called DataClasses.dbml in the App_Code folder using "Add New Item..." context menu action.

linq new dbml

3. Create the entity classes

Drag the tables from the Server Explorer to the DataClasses.dbml window.

linq dbml drag

You can adjust the properties of the entities using the Properties editor. The code will be generated automatically (DataClasses.designer.cs).

linq dbml entities

4. The LINQ Code

What follows is a simple code that loads the resources (resource table) and events (event table) to the Scheduler control. The Dps control is added dynamically using a PlaceHolder but it could be added directly to the aspx as well.


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>DayPilot and LINQ</title>
    <form id="form1" runat="server">
    <asp:PlaceHolder ID="Placeholder" runat="server"></asp:PlaceHolder>


using System;
using System.Linq;
using DayPilot.Web.Ui;

public partial class _Default : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e)
        var start = new DateTime(2010, 1, 1);
        var end = new DateTime(2011, 1, 1);

        var db = new DataClassesDataContext();
        var events = from ev in db.Events where !(ev.eventend <= start || ev.eventstart >= end) select ev;
        var resources = from res in db.Resources orderby select res;

        var dps = new DayPilotScheduler();
        foreach(var r in resources)

        dps.DataSource = events;
        dps.DataStartField = "eventstart";
        dps.DataEndField = "eventend";
        dps.DataValueField = "id";
        dps.DataTextField = "text";
        dps.DataResourceField = "resource_id";



How to show a modal dialog in ASP.NET MVC 3 Razor
How to show the selected date using a Label control
Recommended Doctypes
How to copy events using drag&drop (Ctrl key)