DayPilot - Open-Source Outlook-Like Calendar/Scheduling Control for ASP.NET
Try the online demo: AJAX-style event creating, moving, resizing, and deleting • Context menu • Day view • Work week view • Week view • Month view • Horizontal/vertical resources view • PostBack/AJAX/JavaScript event handling • Binding to XmlDataSource, SqlDataSource, DataTable, ArrayList • Custom event formatting • UpdatePanel compatibility

Data binding

Data source

Create a new datasource and assign the control ID to DataSourceID property in the designer (ASPX template):

<DayPilot:DayPilotCalendar ID="DayPilotCalendar1" runat="server" 
DataSourceID="SqlDataSource1"
DataTextField="name"
DataValueField="id"
StartDate="2007-01-01"
DataStartField="Start"
DataEndField="End"  >
</DayPilot:DayPilotCalendar>

You can also assign data source directly using DataSource property (in the code only):

DayPilotCalendar1.DataSource = MyDataSource;

The data source must implement IListSource, IEnumerable or IDataSource interface. That is for example:

  • XmlDataSource
  • SqlDataSource
  • ArrayList
  • DataTable
  • DataSet (first DataTable will be loaded)

Columns

You need to specify which columns of the data source will be used:

Property Required Column type Column purpose
DataStartField Yes DateTime Event start date & time.
DataEndField Yes DateTime Event end date & time.
DataValueField Yes string Event primary key (id).
DataTextField Yes string Event name (description).
DataColumnField In Resources view string Id of the column where the event should appear (used for Resources view, ViewType="Resources").
DataTagField No string Event custom data (use it to pass additional information to event handlers).

The column content will be converted to DateTime/string using Convert.ToDateTime()/Convert.ToString(). That means that the type doesn't have to be the same in the database. However, it must be convertible to the target type.

Data binding

To load the data from the data source you need to call DataBind() method:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataBind();
        }
    }

In the event handler (when handling either PostBack or CallBack) you need to call DataBind() again if you have changed the data (e.g., after modifying the event duration in EventResize handler). If you use CallBack handling rather than PostBack, you need to call Update() method to send the changes back to the control:

protected void DayPilotCalendar1_EventResize(object sender, EventResizeEventArgs e)
{

// Update your data source here
// ...


    DayPilotCalendar1.DataBind();
    DayPilotCalendar1.Update(); // necessary for handling CallBack, but won't hurt for PostBack
}

By default the event data are stored in the ViewState. It doesn't store the complete data source:

  • It selects only the values defined in DataValueField, DataTextField, DataColumnField, DataStartField, DataEndField columns from the data source.
  • It selects only the events that are within the time range specified by StartDate and Days properties.

DayPilot Pro is an advanced DayPilot edition. You can check a thumbnail overview of the most interesting features. There is also an online demo with all the features working (including the AJAX features). If you want to test the design-time support and API you can download a fully functional trial version. And if you like it, you can buy a full version with source code and 12 months of upgrades and support (with a 30-days money back guarantee).

DayPilot Lite is a do-it-yourself open-source edition of DayPilot. Although it misses some DayPilot Pro features, there are thousands of developers using it to build calendar, personal scheduling, and resource booking applications.

Questions or suggestions? Try DayPilot forums or contact us directly.