ListView.OnItemCommand(ListViewCommandEventArgs) 方法

定义

引发 ItemCommand 事件。Raises the ItemCommand event.

protected:
 virtual void OnItemCommand(System::Web::UI::WebControls::ListViewCommandEventArgs ^ e);
protected virtual void OnItemCommand (System.Web.UI.WebControls.ListViewCommandEventArgs e);
abstract member OnItemCommand : System.Web.UI.WebControls.ListViewCommandEventArgs -> unit
override this.OnItemCommand : System.Web.UI.WebControls.ListViewCommandEventArgs -> unit
Protected Overridable Sub OnItemCommand (e As ListViewCommandEventArgs)

参数

e
ListViewCommandEventArgs

事件数据。The event data.

注解

ItemCommand当单击项模板中的按钮时,但在执行该命令之前,会引发事件。The ItemCommand event is raised when a button in an item template is clicked, but before the command is executed. 这使您可以在 CommandName CommandArgument 每次发生此事件时执行自定义例程,以响应提供的或值。This enables you to perform a custom routine in response to the supplied CommandName or CommandArgument value whenever this event occurs.

OnItemCommand 方法由 ListView 控件调用以引发 ItemCommand 事件。The OnItemCommand method is called by the ListView control to raise the ItemCommand event. 它通常由控件开发人员在扩展类时使用 ListViewIt is typically used by control developers when extending the ListView class.

引发事件时,将通过委托调用事件处理程序。Raising an event invokes the event handler through a delegate. 有关详细信息,请参阅 处理和引发事件For more information, see Handling and Raising Events.

OnItemCommand方法还使派生类可以处理事件,而无需附加委托。The OnItemCommand method also enables derived classes to handle the event without attaching a delegate. 这是在派生类中处理事件的首选技术。This is the preferred technique for handling the event in a derived class.

继承者说明

当在 OnItemCommand(ListViewCommandEventArgs) 派生类中重写时,调用基类的 OnItemCommand(ListViewCommandEventArgs) 方法,以便注册的委托接收事件。When you override OnItemCommand(ListViewCommandEventArgs) in a derived class, call the base class's OnItemCommand(ListViewCommandEventArgs) method so that registered delegates receive the event.

适用于

另请参阅