LinqDataSourceDeleteEventArgs Classe

Definição

Fornece dados para o evento de Deleting .Provides data for the Deleting event.

public ref class LinqDataSourceDeleteEventArgs : System::ComponentModel::CancelEventArgs
public class LinqDataSourceDeleteEventArgs : System.ComponentModel.CancelEventArgs
type LinqDataSourceDeleteEventArgs = class
    inherit CancelEventArgs
Public Class LinqDataSourceDeleteEventArgs
Inherits CancelEventArgs
Herança
LinqDataSourceDeleteEventArgs

Exemplos

O exemplo a seguir mostra como cancelar a operação de exclusão com base em uma propriedade na OriginalObject propriedade e um valor da página da Web.The following example shows how to cancel the delete operation based on a property in the OriginalObject property and a value from the Web page. No exemplo, os usuários devem selecionar um CheckBox controle para confirmar que eles desejam excluir um registro de produto quando sua OnSale propriedade for definida como true .In the example, users must select a CheckBox control to confirm that they want to delete a product record when its OnSale property is set to true.

protected void LinqDataSource_Deleting(object sender, LinqDataSourceDeleteEventArgs e)
{
    Product product = (Product)e.OriginalObject;
    if (product.OnSale && !confirmCheckBox.Checked)
    {
        e.Cancel = true;
    }
}
Protected Sub LinqDataSource_Deleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs)
    Dim product As Product
    product = CType(e.OriginalObject, Product)

    If (product.OnSale And Not confirmCheckBox.Checked) Then
        e.Cancel = True
    End If
End Sub

Comentários

O LinqDataSourceDeleteEventArgs objeto é passado para qualquer manipulador para o Deleting evento.The LinqDataSourceDeleteEventArgs object is passed to any handler for the Deleting event. A OriginalObject propriedade contém os dados que serão excluídos.The OriginalObject property contains the data that will be deleted.

Se o objeto que representa a fonte de dados lançar uma exceção de validação antes de excluir os dados, a Exception Propriedade conterá uma instância da LinqDataSourceValidationException classe.If the object that represents the data source throws a validation exception before it deletes the data, the Exception property contains an instance of the LinqDataSourceValidationException class. Você pode recuperar todas as exceções de validação por meio da InnerExceptions propriedade.You can retrieve all the validation exceptions through the InnerExceptions property. Se nenhuma exceção de validação for gerada, a Exception Propriedade conterá null .If no validation exception is thrown, the Exception property contains null. Se você tratar as exceções de validação e não quiser que a exceção seja relançada, defina a ExceptionHandled propriedade como true .If you handle the validation exceptions and do not want the exception to be re-thrown, set the ExceptionHandled property to true.

Você cria um manipulador de eventos para o Deleting evento para validar os dados, para examinar erros de validação da classe de dados ou para cancelar a operação de exclusão.You create an event handler for the Deleting event to validate the data, to examine validation errors from the data class, or to cancel the delete operation. Cancele a operação de exclusão definindo a Cancel propriedade como true .You cancel the delete operation by setting the Cancel property to true.

Por padrão, o LinqDataSource controle armazena os valores originais da fonte de dados no estado de exibição na página da Web, exceto aqueles cujo ColumnAttribute atributo está marcado como UpdateCheck.Never .By default, the LinqDataSource control stores the original values from the data source in view state in the Web page, except those whose ColumnAttribute attribute is marked as UpdateCheck.Never. LINQ to SQL verifica automaticamente a integridade dos dados antes de excluir os dados.LINQ to SQL automatically checks the integrity of the data before deleting the data. Ele faz isso comparando os valores atuais na fonte de dados com os valores originais que são armazenados no estado de exibição.It does this by comparing the current values in the data source with the original values that are stored in view state. Você pode executar a validação de dados adicional criando um manipulador para o Deleting evento.You can perform additional data validation by creating a handler for the Deleting event.

Construtores

LinqDataSourceDeleteEventArgs(LinqDataSourceValidationException)

Inicializa uma nova instância da classe LinqDataSourceDeleteEventArgs com a exceção especificada.Initializes a new instance of the LinqDataSourceDeleteEventArgs class with the specified exception.

LinqDataSourceDeleteEventArgs(Object)

Inicializa uma nova instância da classe LinqDataSourceDeleteEventArgs.Initializes a new instance of the LinqDataSourceDeleteEventArgs class.

Propriedades

Cancel

Obtém ou define um valor que indica se o evento deve ser cancelado.Gets or sets a value indicating whether the event should be canceled.

(Herdado de CancelEventArgs)
Exception

Obtém a exceção gerada enquanto os dados estavam sendo validados antes da operação de exclusão.Gets the exception that was thrown while the data was being validated before the delete operation.

ExceptionHandled

Obtém ou define um valor que indica se a exceção foi tratada e que ela não deve ser gerada novamente.Gets or sets a value that indicates whether the exception was handled and that it should not be thrown again.

OriginalObject

Obtém o objeto que representa os dados serem excluídos.Gets the object that represents the data to delete.

Métodos

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Aplica-se a