EntityDataSource.ContextCreated 事件

定義

EntityDataSource 已完成建立用於搭配實體資料物件使用的 ObjectContext 時發生。Occurs when the EntityDataSource has finished creating the ObjectContext that is used to work with entity data objects.

public:
 event EventHandler<System::Web::UI::WebControls::EntityDataSourceContextCreatedEventArgs ^> ^ ContextCreated;
public event EventHandler<System.Web.UI.WebControls.EntityDataSourceContextCreatedEventArgs> ContextCreated;
member this.ContextCreated : EventHandler<System.Web.UI.WebControls.EntityDataSourceContextCreatedEventArgs> 
Public Custom Event ContextCreated As EventHandler(Of EntityDataSourceContextCreatedEventArgs) 

事件類型

EventHandler<EntityDataSourceContextCreatedEventArgs>

備註

處理這個事件,以存取 ObjectContext EntityDataSource 控制項用來執行查詢和追蹤變更的。Handle this event to access the ObjectContext that is used by the EntityDataSource control to execute the query and track changes. 這個內容物件可以儲存起來,並用於以外的後續作業 EntityDataSourceThis context object can be stored and used for successive operations outside the EntityDataSource. ObjectContext是從 EntityDataSourceContextCreatedEventArgs 事件傳回的取得 ContextCreatedThe ObjectContext is obtained from the EntityDataSourceContextCreatedEventArgs that is returned by the ContextCreated event. 如需詳細資訊,請參閱 物件內容生命週期管理 (EntityDataSource) For more information, see Object Context Life-Cycle Management (EntityDataSource). 如需物件內容的詳細資訊,請參閱 識別解析、狀態管理和變更追蹤For more information about the object context, see Identity Resolution, State Management, and Change Tracking.

ContextCreated事件可讓您將已建立的指派 ObjectContext 給以外的後續作業 EntityDataSourceThe ContextCreated event allows you to assign the ObjectContext that has been created to a variable for successive operations outside the EntityDataSource. EntityDataSourceContextCreatedEventArgs.Context屬性包含事件中已建立的內容 ContextCreatingThe EntityDataSourceContextCreatedEventArgs.Context property contains the context that has been created in the ContextCreating event. 如果使用者未在事件期間指派內容,則 ContextCreating 中包含的內容實例 EntityDataSourceContextCreatedEventArgs.Context 就是 EntityDataSource 根據 EntityDataSource.ContextTypeNameEntityDataSource.DefaultContainerName 或屬性所建立的 EntityDataSource.ConnectionStringIf the user does not assign a context during the ContextCreating event, the context instance contained in EntityDataSourceContextCreatedEventArgs.Context is the one created by the EntityDataSource based on the EntityDataSource.ContextTypeName, EntityDataSource.DefaultContainerName, or EntityDataSource.ConnectionString properties.

適用於