Example E489
Visible to All Users

Scheduler for ASP.NET Web Forms - How to enhance scheduler performance when handling a large number of appointments

This example demonstrates how to handle the FetchAppointments event to dynamically limit the number of appointments loaded into the scheduler storage. This approach can be useful when a scheduler contains a large amount of data, and only a small part of it needs to be loaded at one time.

C#
protected void ASPxScheduler1_FetchAppointments(object sender, DevExpress.XtraScheduler.FetchAppointmentsEventArgs e) { SetAppointmentDataSourceSelectCommandParameters(e.Interval); e.ForceReloadAppointments = true; } protected void SetAppointmentDataSourceSelectCommandParameters(TimeInterval interval) { SqlDataSource1.SelectParameters["OriginalOccurrenceStart"].DefaultValue = interval.Start.ToString(); SqlDataSource1.SelectParameters["OriginalOccurrenceEnd"].DefaultValue = interval.End.ToString(); }

Files to Review

Documentation

More Examples

Example Code

Default.aspx
ASPx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly="DevExpress.Web.ASPxScheduler.v17.1, Version=17.1.17.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxScheduler" TagPrefix="dxwschs" %> <%@ Register Assembly="DevExpress.XtraScheduler.v17.1.Core, Version=17.1.17.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.XtraScheduler" TagPrefix="cc1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <dxwschs:ASPxScheduler ID="ASPxScheduler1" runat="server" Width="800px" AppointmentDataSourceID="SqlDataSource1" ClientIDMode="AutoID" Start="2017-12-22" ResourceDataSourceID="SqlDataSource2" GroupType="Resource" OnFetchAppointments="ASPxScheduler1_FetchAppointments"> <Storage> <Appointments AutoRetrieveId="True"> <Mappings AllDay="AllDay" AppointmentId="UniqueID" Description="Description" End="EndDate" Label="Label" Location="Location" RecurrenceInfo="RecurrenceInfo" ReminderInfo="ReminderInfo" ResourceId="ResourceID" Start="StartDate" Status="Status" Subject="Subject" Type="Type" OriginalOccurrenceEnd="OriginalOccurrenceEnd" OriginalOccurrenceStart="OriginalOccurrenceStart" /> <CustomFieldMappings> <dxwschs:ASPxAppointmentCustomFieldMapping Member="CustomField1" Name="CustomField1" /> </CustomFieldMappings> </Appointments> <Resources> <Mappings Caption="ResourceName" Color="Color" Image="Image" ResourceId="ResourceID" /> <CustomFieldMappings> <dxwschs:ASPxResourceCustomFieldMapping Member="CustomField1" Name="CustomField1" /> </CustomFieldMappings> </Resources> </Storage> <Views> <DayView> <TimeRulers> <cc1:TimeRuler></cc1:TimeRuler> </TimeRulers> <AppointmentDisplayOptions ColumnPadding-Left="2" ColumnPadding-Right="4"></AppointmentDisplayOptions> <DayViewStyles ScrollAreaHeight="600px"></DayViewStyles> </DayView> <WorkWeekView> <TimeRulers> <cc1:TimeRuler></cc1:TimeRuler> </TimeRulers> <AppointmentDisplayOptions ColumnPadding-Left="2" ColumnPadding-Right="4"></AppointmentDisplayOptions> </WorkWeekView> <WeekView Enabled="false"></WeekView> <MonthView></MonthView> <TimelineView></TimelineView> <FullWeekView Enabled="true"> <TimeRulers> <cc1:TimeRuler></cc1:TimeRuler> </TimeRulers> <AppointmentDisplayOptions ColumnPadding-Left="2" ColumnPadding-Right="4"></AppointmentDisplayOptions> </FullWeekView> <AgendaView></AgendaView> </Views> <OptionsToolTips AppointmentToolTipCornerType="None"></OptionsToolTips> </dxwschs:ASPxScheduler> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestConnectionString %>" SelectCommand="SELECT * FROM [Appointments] WHERE ((OriginalOccurrenceStart >= @OriginalOccurrenceStart) AND (OriginalOccurrenceEnd <= @OriginalOccurrenceEnd)) OR ((OriginalOccurrenceStart >= @OriginalOccurrenceStart) AND (OriginalOccurrenceStart <= @OriginalOccurrenceEnd)) OR ((OriginalOccurrenceEnd >= @OriginalOccurrenceStart) AND (OriginalOccurrenceEnd <= @OriginalOccurrenceEnd)) OR ((OriginalOccurrenceStart < @OriginalOccurrenceStart) AND (OriginalOccurrenceEnd > @OriginalOccurrenceEnd)) OR (Type <> 0)" DeleteCommand="DELETE FROM [Appointments] WHERE [UniqueID] = @UniqueID" InsertCommand="INSERT INTO [Appointments] ([Type], [StartDate], [EndDate], [AllDay], [Subject], [Location], [Description], [Status], [Label], [ResourceID], [ResourceIDs], [ReminderInfo], [RecurrenceInfo], [CustomField1], [OriginalOccurrenceStart], [OriginalOccurrenceEnd]) VALUES (@Type, @StartDate, @EndDate, @AllDay, @Subject, @Location, @Description, @Status, @Label, @ResourceID, @ResourceIDs, @ReminderInfo, @RecurrenceInfo, @CustomField1, @OriginalOccurrenceStart, @OriginalOccurrenceEnd)" UpdateCommand="UPDATE [Appointments] SET [Type] = @Type, [StartDate] = @StartDate, [EndDate] = @EndDate, [AllDay] = @AllDay, [Subject] = @Subject, [Location] = @Location, [Description] = @Description, [Status] = @Status, [Label] = @Label, [ResourceID] = @ResourceID, [ResourceIDs] = @ResourceIDs, [ReminderInfo] = @ReminderInfo, [RecurrenceInfo] = @RecurrenceInfo, [CustomField1] = @CustomField1, [OriginalOccurrenceStart] = @OriginalOccurrenceStart, [OriginalOccurrenceEnd] = @OriginalOccurrenceEnd WHERE [UniqueID] = @UniqueID"> <DeleteParameters> <asp:Parameter Name="UniqueID" Type="Int32" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="Type" Type="Int32" /> <asp:Parameter Name="StartDate" Type="DateTime" /> <asp:Parameter Name="EndDate" Type="DateTime" /> <asp:Parameter Name="AllDay" Type="Boolean" /> <asp:Parameter Name="Subject" Type="String" /> <asp:Parameter Name="Location" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Status" Type="Int32" /> <asp:Parameter Name="Label" Type="Int32" /> <asp:Parameter Name="ResourceID" Type="Int32" /> <asp:Parameter Name="ResourceIDs" Type="String" /> <asp:Parameter Name="ReminderInfo" Type="String" /> <asp:Parameter Name="RecurrenceInfo" Type="String" /> <asp:Parameter Name="CustomField1" Type="String" /> <asp:Parameter Name="OriginalOccurrenceStart" Type="DateTime" /> <asp:Parameter Name="OriginalOccurrenceEnd" Type="DateTime" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="Type" Type="Int32" /> <asp:Parameter Name="StartDate" Type="DateTime" /> <asp:Parameter Name="EndDate" Type="DateTime" /> <asp:Parameter Name="AllDay" Type="Boolean" /> <asp:Parameter Name="Subject" Type="String" /> <asp:Parameter Name="Location" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Status" Type="Int32" /> <asp:Parameter Name="Label" Type="Int32" /> <asp:Parameter Name="ResourceID" Type="Int32" /> <asp:Parameter Name="ResourceIDs" Type="String" /> <asp:Parameter Name="ReminderInfo" Type="String" /> <asp:Parameter Name="RecurrenceInfo" Type="String" /> <asp:Parameter Name="CustomField1" Type="String" /> <asp:Parameter Name="OriginalOccurrenceStart" Type="DateTime" /> <asp:Parameter Name="OriginalOccurrenceEnd" Type="DateTime" /> <asp:Parameter Name="UniqueID" Type="Int32" /> </UpdateParameters> <SelectParameters> <asp:Parameter Name="OriginalOccurrenceStart" Type="DateTime" /> <asp:Parameter Name="OriginalOccurrenceEnd" Type="DateTime" /> </SelectParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TestConnectionString %>" SelectCommand="SELECT * FROM [Resources]"></asp:SqlDataSource> </div> </form> </body> </html>
Default.aspx.cs(vb)
C#
using DevExpress.XtraScheduler; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void ASPxScheduler1_FetchAppointments(object sender, DevExpress.XtraScheduler.FetchAppointmentsEventArgs e) { SetAppointmentDataSourceSelectCommandParameters(e.Interval); e.ForceReloadAppointments = true; } protected void SetAppointmentDataSourceSelectCommandParameters(TimeInterval interval) { SqlDataSource1.SelectParameters["OriginalOccurrenceStart"].DefaultValue = interval.Start.ToString(); SqlDataSource1.SelectParameters["OriginalOccurrenceEnd"].DefaultValue = interval.End.ToString(); } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.