ListView.OnItemInserting(ListViewInsertEventArgs) Método

Definição

Aciona o evento ItemInserting.Raises the ItemInserting event.

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

Parâmetros

e
ListViewInsertEventArgs

Os dados do evento.The event data.

Exceções

O controle ListView não está associado a um controle de fonte de dados usando a propriedade DataSourceID.The ListView control is not bound to a data source control by using the DataSourceID property.

Comentários

O ListView controle gera o ItemInserting evento quando um botão de inserção no controle é clicado ou o InsertNewItem método é chamado, mas antes de o ListView controle inserir o registro.The ListView control raises the ItemInserting event when an Insert button in the control is clicked or the InsertNewItem method is called, but before the ListView control inserts the record. (Um botão de inserção é um controle de botão cuja CommandName propriedade é definida como "Inserir".) Isso permite que você execute uma rotina personalizada sempre que esse evento ocorrer, como codificação HTML ou validação dos valores de um registro antes que ele seja inserido na fonte de dados.(An Insert button is a button control whose CommandName property is set to "Insert".) This enables you to perform a custom routine whenever this event occurs, such as HTML-encoding or validating the values of a record before it is inserted in the data source.

O OnItemInserting método é chamado pelo ListView controle para gerar o ItemInserting evento.The OnItemInserting method is called by the ListView control to raise the ItemInserting event. Normalmente, ele é usado por desenvolvedores de controle ao estender a ListView classe.It is typically used by control developers when extending the ListView class.

A geração de um evento invoca o manipulador de eventos por meio de um delegado.Raising an event invokes the event handler through a delegate. Para obter mais informações, consulte manipulando e gerando eventos.For more information, see Handling and Raising Events.

O OnItemInserting método também permite que classes derivadas manipulem o evento sem anexar um delegado.The OnItemInserting method also enables derived classes to handle the event without attaching a delegate. Essa é a técnica preferida para manipular o evento em uma classe derivada.This is the preferred technique for handling the event in a derived class.

Notas aos Herdeiros

Quando você substitui OnItemInserting(ListViewInsertEventArgs) em uma classe derivada, chame o método da classe base OnItemInserting(ListViewInsertEventArgs) para que os delegados registrados recebam o evento.When you override OnItemInserting(ListViewInsertEventArgs) in a derived class, call the base class's OnItemInserting(ListViewInsertEventArgs) method so that registered delegates receive the event.

Aplica-se a

Confira também