Suggérer une traduction
 
Suggestions d'autres utilisateurs :

progress indicator
Aucune autre suggestion.
Cliquez pour évaluer et commenter
MSDN
MSDN Library
Développement .NET
.NET Framework 4
Espaces de noms System.Web
System.Web.UI.WebControls
Réduire tout/Développer tout Réduire tout
Affichage du contenu :  côte à côteAffichage du contenu : côte à côte
.NET Framework Class Library
LinqDataSourceDeleteEventArgs Class

Provides data for the Deleting event.

System..::.Object
  System..::.EventArgs
    System.ComponentModel..::.CancelEventArgs
      System.Web.UI.WebControls..::.LinqDataSourceDeleteEventArgs

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)
Visual Basic
Public Class LinqDataSourceDeleteEventArgs _
    Inherits CancelEventArgs
C#
public class LinqDataSourceDeleteEventArgs : CancelEventArgs
Visual C++
public ref class LinqDataSourceDeleteEventArgs : public CancelEventArgs
F#
type LinqDataSourceDeleteEventArgs =  
    class
        inherit CancelEventArgs
    end

The LinqDataSourceDeleteEventArgs type exposes the following members.

  NameDescription
Public methodLinqDataSourceDeleteEventArgs(LinqDataSourceValidationException)Initializes a new instance of the LinqDataSourceDeleteEventArgs class with the specified exception.
Public methodLinqDataSourceDeleteEventArgs(Object)Initializes a new instance of the LinqDataSourceDeleteEventArgs class.
Top
  NameDescription
Public propertyCancelGets or sets a value indicating whether the event should be canceled. (Inherited from CancelEventArgs.)
Public propertyExceptionGets the exception that was thrown while the data was being validated before the delete operation.
Public propertyExceptionHandledGets or sets a value that indicates whether the exception was handled and that it should not be thrown again.
Public propertyOriginalObjectGets the object that represents the data to delete.
Top
  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The LinqDataSourceDeleteEventArgs object is passed to any handler for the Deleting event. The OriginalObject property contains the data that will be deleted.

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. You can retrieve all the validation exceptions through the InnerExceptions property. If no validation exception is thrown, the Exception property contains nullNothingnullptra null reference (Nothing in Visual Basic). If you handle the validation exceptions and do not want the exception to be re-thrown, set the ExceptionHandled property to true.

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. You cancel the delete operation by setting the Cancel property to true.

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 automatically checks the integrity of the data before deleting the data. It does this by comparing the current values in the data source with the original values that are stored in view state. You can perform additional data validation by creating a handler for the Deleting event.

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. 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.

Visual Basic
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
C#
protected void LinqDataSource_Deleting(object sender, LinqDataSourceDeleteEventArgs e)
{
    Product product = (Product)e.OriginalObject;
    if (product.OnSale && !confirmCheckBox.Checked)
    {
        e.Cancel = true;
    }
}

.NET Framework

Supported in: 4, 3.5

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Bibliothèque de classes .NET Framework
LinqDataSourceDeleteEventArgs, classe

Fournit des données pour l'événement Deleting.

System..::.Object
  System..::.EventArgs
    System.ComponentModel..::.CancelEventArgs
      System.Web.UI.WebControls..::.LinqDataSourceDeleteEventArgs

Espace de noms :  System.Web.UI.WebControls
Assembly :  System.Web.Extensions (dans System.Web.Extensions.dll)
Visual Basic
Public Class LinqDataSourceDeleteEventArgs _
    Inherits CancelEventArgs
C#
public class LinqDataSourceDeleteEventArgs : CancelEventArgs
VisualC++
public ref class LinqDataSourceDeleteEventArgs : public CancelEventArgs
F#
type LinqDataSourceDeleteEventArgs =  
    class
        inherit CancelEventArgs
    end

Le type LinqDataSourceDeleteEventArgs expose les membres suivants.

  NomDescription
Méthode publiqueLinqDataSourceDeleteEventArgs(LinqDataSourceValidationException)Initialise une nouvelle instance de la classe LinqDataSourceDeleteEventArgs avec l'exception spécifiée.
Méthode publiqueLinqDataSourceDeleteEventArgs(Object)Initialise une nouvelle instance de la classe LinqDataSourceDeleteEventArgs.
Début
  NomDescription
Propriété publiqueCancelObtient ou définit une valeur indiquant si l'événement doit être annulé. (Hérité de CancelEventArgs.)
Propriété publiqueExceptionObtient l'exception levée lors de la validation des données avant l'opération de suppression.
Propriété publiqueExceptionHandledObtient ou définit une valeur qui indique si l'exception a été gérée et qu'elle ne doit plus être levée.
Propriété publiqueOriginalObjectObtient l'objet qui représente les données à supprimer.
Début
  NomDescription
Méthode publiqueEquals(Object)Détermine si l'Object spécifié est égal à l'Object en cours. (Hérité de Object.)
Méthode protégéeFinalizeAutorise un objet à tenter de libérer des ressources et d'exécuter d'autres opérations de netto***ge avant qu'il ne soit récupéré par l'opération garbage collection. (Hérité de Object.)
Méthode publiqueGetHashCodeSert de fonction de hachage pour un type particulier. (Hérité de Object.)
Méthode publiqueGetTypeObtient le Type de l'instance actuelle. (Hérité de Object.)
Méthode protégéeMemberwiseCloneCrée une copie superficielle de l'objet Object actif. (Hérité de Object.)
Méthode publiqueToStringRetourne une chaîne qui représente l'objet actuel. (Hérité de Object.)
Début

L'objet LinqDataSourceDeleteEventArgs est passé à un gestionnaire pour l'événement Deleting. La propriété OriginalObject contient les données qui seront supprimées.

Si l'objet qui représente la source de données lève une exception de validation avant la suppression des données, la propriété Exception contient une instance de la classe LinqDataSourceValidationException. Vous pouvez alors récupérer toutes les exceptions de validation par l'intermédiaire de la propriété InnerExceptions. Si aucune exception de validation n'est levée, la propriété Exception contient nullNothingnullptrune référence null (Nothing en Visual Basic). Si vous gérez les exceptions de validation et souhaitez qu'elles ne soient plus levées, affectez la valeur true à la propriété ExceptionHandled.

Vous créez un gestionnaire d'événements pour que l'événement Deleting valide les données, pour examiner les erreurs de validation de la classe de données ou pour annuler l'opération de suppression. Vous annulez l'opération de suppression en affectant la valeur true à la propriété Cancel.

Par défaut, le contrôle LinqDataSource stocke les valeurs d'origine de la source de données dans la page Web dans l'état d'affichage, sauf celles dont l'attribut ColumnAttribute est marqué comme UpdateCheck.Never. La requête LINQ to SQL vérifie automatiquement l'intégrité des données avant de les supprimer. Pour cela, elle compare les valeurs en cours de la source de données avec les valeurs d'origine stockées dans l'état d'affichage. Vous pouvez exécuter une validation supplémentaire des données en créant un gestionnaire pour l'événement Deleting.

L'exemple suivant indique comment annuler l'opération de suppression en fonction d'une propriété dans la propriété OriginalObject et d'une valeur de la page Web. Dans l'exemple, les utilisateurs doivent sélectionner un contrôle CheckBox pour confirmer qu'ils souhaitent supprimer un enregistrement de produit lorsque sa propriété OnSale a la valeur true.

Visual Basic
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
C#
protected void LinqDataSource_Deleting(object sender, LinqDataSourceDeleteEventArgs e)
{
    Product product = (Product)e.OriginalObject;
    if (product.OnSale && !confirmCheckBox.Checked)
    {
        e.Cancel = true;
    }
}

.NET Framework

Pris en charge dans : 4, 3.5

Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2

Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Tous les membres static (Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.
Contenu de la communauté   Qu'est-ce que le Contenu de la communauté ?
Ajouter du contenu RSS  Annotations
Processing
© 2012 Microsoft. Tous droits réservés. Conditions d'utilisation | Marques | Confidentialité
Page view tracker