Skip to main content

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.v24.2.dll

Declaration

[DefaultValue(false)]
public bool AutoRetrieveId { get; set; }

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:

View Example

// 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);
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AutoRetrieveId property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also