ASPxAppointmentStorage.AutoRetrieveId Property

Gets or sets whether the ID of a new appointment is retrieved from the data source.

Namespace: DevExpress.Web.ASPxScheduler

Assembly: DevExpress.Web.ASPxScheduler.v20.1.dll

Declaration

[DefaultValue(false)]
public bool AutoRetrieveId { get; set; }
<DefaultValue(False)>
Public Property AutoRetrieveId As Boolean

Property Value

Type Default Description
Boolean

false

true, to get the appointment ID for a newly created appointment from the data source; otherwise, false.

Remarks

The AutoRetrieveId option is only valid for the ObjectDataSource and the SqlDataSource data controls bound to the Scheduler.

IMPORTANT

For the AutoRetrieveId property to have effect, the object data source should meet the following requirements:

  • INSERT method returns the appointment ID
  • a data source field, which maps to the appointment ID, is writable

When the AutoRetrieveId is set to true, a newly created appointment obtains its ID from the data source. This scenario assumes that the data source generates the primary key (identity) for inserted data rows automatically. After a new appointment record is written, its ID is fetched and assigned to the Appointment instance in the Scheduler storage. Therefore, appointment unique identifiers in the Scheduler storage are the same as for the appointments in the data source.

The AutoRetrieveId option replaces the following code that has been used previously for MS SQL Server and object data sources:

// The following code is unnecessary if the ASPxScheduler.Storage.Appointments.AutoRetrieveId option is TRUE.
protected void ASPxScheduler1_AppointmentInserted(object sender, DevExpress.XtraScheduler.PersistentObjectsEventArgs e)
{
    SetAppointmentId(sender, e);
}
protected void appointmentsDataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
{
    this.lastInsertedAppointmentId = e.ReturnValue;
}
void SetAppointmentId(object sender, DevExpress.XtraScheduler.PersistentObjectsEventArgs e)
{
    DevExpress.Web.ASPxScheduler.ASPxSchedulerStorage storage = (DevExpress.Web.ASPxScheduler.ASPxSchedulerStorage)sender;
    DevExpress.XtraScheduler.Appointment apt = (DevExpress.XtraScheduler.Appointment)e.Objects[0];
    storage.SetAppointmentId(apt, this.lastInsertedAppointmentId);
}

Implements

DevExpress.Web.ASPxScheduler.IASPxAppointmentStorage.AutoRetrieveId
See Also