SqlDataSourceSelectingEventArgs 類別


提供 Selecting 控制項的 SqlDataSource 事件資料。Provides data for the Selecting event of the SqlDataSource control.

public ref class SqlDataSourceSelectingEventArgs : System::Web::UI::WebControls::SqlDataSourceCommandEventArgs
public class SqlDataSourceSelectingEventArgs : System.Web.UI.WebControls.SqlDataSourceCommandEventArgs
type SqlDataSourceSelectingEventArgs = class
    inherit SqlDataSourceCommandEventArgs
Public Class SqlDataSourceSelectingEventArgs
Inherits SqlDataSourceCommandEventArgs


藉由新增事件處理常式委派來處理 Selecting 事件,您可以執行任何其他必要的前置處理,或完全取消資料庫查詢。By adding an event handler delegate to handle the Selecting event, you can perform any additional preprocessing required or cancel the database query entirely. 因為 SqlDataSourceSelectingEventArgs 類別衍生自 SqlDataSourceCommandEventArgs 類別,所以您可以 SqlDataSource 將屬性設定為,以取消暫止的資料庫查詢 Cancel trueBecause the SqlDataSourceSelectingEventArgs class is derived from the SqlDataSourceCommandEventArgs class, you can cancel a pending SqlDataSource database query by setting the Cancel property to true. 您可以藉 CommandText 由存取屬性所公開的物件,在執行查詢之前,檢查和操作、 Parameters 集合和其他資料庫查詢屬性 DbCommand CommandYou can examine and manipulate the CommandText, Parameters collection, and other database query properties prior to running the query by accessing the DbCommand object exposed by the Command property. 您也可以藉 DataSourceSelectArguments 由存取屬性,檢查傳遞給 Select 方法的物件 ArgumentsYou can also examine the DataSourceSelectArguments object that is passed to the Select method by accessing the Arguments property.

SqlDataSourceSelectingEventArgs類別會在方法中用 OnSelecting 來提供資料庫查詢的存取權, SqlDataSource 然後才執行它。The SqlDataSourceSelectingEventArgs class is used in the OnSelecting method to provide access to a SqlDataSource database query before it is run.

SqlDataSource控制項會公開許多事件,讓您可以處理這些事件,以在資料作業過程中處理基礎資料物件。The SqlDataSource control exposes many events that you can handle to work with the underlying data objects during the course of a data operation. 下表列出事件和相關聯的 EventArgs 類別,以及事件處理常式委派。The following table lists the events and associated EventArgs classes and event handler delegates.

事件Event EventArgsEventArgs EventHandlerEventHandler

在資料取出之前發生。Occurs before the data is retrieved.
SqlDataSourceSelectingEventArgs SqlDataSourceSelectingEventHandler
InsertingUpdatingDeletingInserting, Updating, and Deleting.

在執行插入、更新或刪除作業之前發生。Occur before an insert, update, or delete operation is performed.
SqlDataSourceCommandEventArgs SqlDataSourceCommandEventHandler
SelectedInsertedUpdatedDeletedSelected, Inserted, Updated, and Deleted.

在資料抓取、插入、更新或刪除作業完成之後發生。Occur after the data retrieval, insert, update, or delete operation completes.
SqlDataSourceStatusEventArgs SqlDataSourceStatusEventHandler


SqlDataSourceSelectingEventArgs(DbCommand, DataSourceSelectArguments)

使用指定的 SqlDataSourceSelectingEventArgs 物件和傳遞至 DbCommand 方法的任何 DataSourceSelectArguments,初始化 Select(DataSourceSelectArguments) 類別的新執行個體。Initializes a new instance of the SqlDataSourceSelectingEventArgs class, using the specified DbCommand object and any DataSourceSelectArguments passed to the Select(DataSourceSelectArguments) method.



取得傳遞至 DataSourceSelectArguments 方法的 Select(DataSourceSelectArguments) 物件。Gets the DataSourceSelectArguments object passed to the Select(DataSourceSelectArguments) method.


取得或設定值,這個值表示是否應該取消事件。Gets or sets a value indicating whether the event should be canceled.

(繼承來源 CancelEventArgs)

取得暫止的資料庫命令。Gets the pending database command.

(繼承來源 SqlDataSourceCommandEventArgs)



判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)