Back to Devexpress

How to: Filter Appointments

aspnet-3845-components-scheduler-examples-data-binding-how-to-filter-appointments.md

latest1.5 KB
Original Source

How to: Filter Appointments

  • Sep 05, 2025

The following example demonstrates how to filter appointments displayed within a scheduler according to a condition. The ASPxSchedulerDataWebControlBase.FilterAppointment event is intended specifically for this purpose. The code below demonstrates how to hide all tentative appointments (those whose status is set to AppointmentStatusType.Tentative).

csharp
using DevExpress.XtraScheduler;
using DevExpress.Web.ASPxScheduler;
// ...

protected void ASPxScheduler1_FilterAppointment(object sender, PersistentObjectCancelEventArgs e) {
    // Filter all tentative appointments.
    object statusKey = ASPxScheduler1.Storage.Appointments.Statuses.GetByType(
        AppointmentStatusType.Tentative);

    e.Cancel = ((Appointment)e.Object).StatusKey == statusKey;
}
vb
Imports DevExpress.XtraScheduler
Imports DevExpress.Web.ASPxScheduler
' ...

Protected Sub ASPxScheduler1_FilterAppointment(ByVal sender As Object, ByVal e As _
PersistentObjectCancelEventArgs) Handles ASPxScheduler1.FilterAppointment

    ' Filter all tentative appointments.
    Dim statusKey As Object = ASPxScheduler1.Storage.Appointments.Statuses.GetByType(AppointmentStatusType.Tentative)
    e.Cancel = (CType(e.Object, Appointment)).StatusKey = statusKey

End Sub