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
ParameterCollection, classe
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
ParameterCollection Class

Represents a collection of Parameter and Parameter-derived objects that are used by data source controls in advanced data-binding scenarios.

System..::.Object
  System.Web.UI..::.StateManagedCollection
    System.Web.UI.WebControls..::.ParameterCollection

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

The ParameterCollection type exposes the following members.

  NameDescription
Public methodParameterCollectionInitializes the class for use by an inherited class instance. This constructor can be called only by an inherited class.
Top
  NameDescription
Public propertyCountGets the number of elements contained in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public propertyItem[([(Int32])])Gets or sets the Parameter object at the specified index in the collection.
Public propertyItem[([(String])])Gets or sets the Parameter object with the specified name in the collection.
Top
  NameDescription
Public methodAdd(Parameter)Appends the specified Parameter object to the end of the collection.
Public methodAdd(String, String)Creates a Parameter object with the specified name and default value, and appends it to the end of the collection.
Public methodAdd(String, DbType, String)Creates a Parameter object with the specified name, database type, and default value, and adds it to the end of the collection.
Public methodAdd(String, TypeCode, String)Creates a Parameter object with the specified name, TypeCode, and default value, and appends it to the end of the collection.
Public methodClearRemoves all items from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public methodContainsDetermines whether the ParameterCollection collection contains a specific value
Public methodCopyTo(Array, Int32)Copies the elements of the StateManagedCollection collection to an array, starting at a particular array index. (Inherited from StateManagedCollection.)
Public methodCopyTo(array<Parameter>[]()[], Int32)Copies a specified index of a parameter array to the parameter collection.
Protected methodCreateKnownTypeCreates an instance of a default Parameter object. (Overrides StateManagedCollection..::.CreateKnownType(Int32).)
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 methodGetEnumeratorReturns an iterator that iterates through the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Protected methodGetKnownTypesGets an array of Parameter types that the ParameterCollection collection can contain. (Overrides StateManagedCollection..::.GetKnownTypes()()().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetValuesGets an ordered collection of Parameter object names and their corresponding values currently contained by the collection.
Public methodIndexOfDetermines the index of a specified Parameter object in the ParameterCollection collection.
Public methodInsertInserts the specified Parameter object into the ParameterCollection collection at the specified index.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnClearWhen overridden in a derived class, performs additional work before the Clear method removes all items from the collection. (Inherited from StateManagedCollection.)
Protected methodOnClearCompletePerforms additional custom processes after clearing the contents of the collection. (Overrides StateManagedCollection..::.OnClearComplete()()().)
Protected methodOnInsertOccurs before the Insert method is called. (Overrides StateManagedCollection..::.OnInsert(Int32, Object).)
Protected methodOnInsertCompleteOccurs after the Insert method completes. (Overrides StateManagedCollection..::.OnInsertComplete(Int32, Object).)
Protected methodOnParametersChangedRaises the ParametersChanged event.
Protected methodOnRemoveWhen overridden in a derived class, performs additional work before the Remove(Object) or RemoveAt(Int32) method removes the specified item from the collection. (Inherited from StateManagedCollection.)
Protected methodOnRemoveCompleteOccurs after the Remove method completes. (Overrides StateManagedCollection..::.OnRemoveComplete(Int32, Object).)
Protected methodOnValidatePerforms additional custom processes when validating a value. (Overrides StateManagedCollection..::.OnValidate(Object).)
Public methodRemoveRemoves the specified Parameter object from the ParameterCollection collection.
Public methodRemoveAtRemoves the Parameter object at the specified index from the ParameterCollection collection.
Public methodSetDirtyForces the entire StateManagedCollection collection to be serialized into view state. (Inherited from StateManagedCollection.)
Protected methodSetDirtyObjectMarks the specified Parameter object as having changed since the last load or save from view state. (Overrides StateManagedCollection..::.SetDirtyObject(Object).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodUpdateValuesIterates through the Parameter objects contained by the collection, and calls the Evaluate method on each one.
Top
  NameDescription
Public eventParametersChangedOccurs when one or more Parameter objects contained by the collection changes state.
Top
  NameDescription
Explicit interface implemetationPrivate propertyICollection..::.CountInfrastructure. Gets the number of elements contained in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyICollection..::.IsSynchronizedInfrastructure. Gets a value indicating whether the StateManagedCollection collection is synchronized (thread safe). This method returns false in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyICollection..::.SyncRootInfrastructure. Gets an object that can be used to synchronize access to the StateManagedCollection collection. This method returns nullNothingnullptra null reference (Nothing in Visual Basic) in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIEnumerable..::.GetEnumeratorInfrastructure. Returns an iterator that iterates through the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.AddAdds an item to the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.ClearInfrastructure. Removes all items from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.ContainsDetermines whether the StateManagedCollection collection contains a specific value. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.IndexOfDetermines the index of a specified item in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.InsertInserts an item into the StateManagedCollection collection at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList..::.IsFixedSizeInfrastructure. Gets a value indicating whether the StateManagedCollection collection has a fixed size. This method returns false in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList..::.IsReadOnlyInfrastructure. Gets a value indicating whether the StateManagedCollection collection is read-only. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList..::.ItemInfrastructure. Gets the IStateManager element at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.RemoveRemoves the first occurrence of the specified object from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList..::.RemoveAtRemoves the IStateManager element at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIStateManager..::.IsTrackingViewStateGets a value indicating whether the StateManagedCollection collection is saving changes to its view state. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager..::.LoadViewStateRestores the previously saved view state of the StateManagedCollection collection and the IStateManager items it contains. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager..::.SaveViewStateSaves the changes to the StateManagedCollection collection and each IStateManager object it contains since the time the page was posted back to the server. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager..::.TrackViewStateCauses the StateManagedCollection collection and each of the IStateManager objects it contains to track changes to their view state so they can be persisted across requests for the same page. (Inherited from StateManagedCollection.)
Top

The ParameterCollection class represents a collection of Parameter objects used in advanced data-binding scenarios with data source controls. The Parameter objects are used to bind the values contained by local Page variables, HTTP cookies, session variables, and other controls' values to data source controls when retrieving, updating, deleting, and inserting data.

Use the ParameterCollection class to programmatically manage a set of Parameter objects. You can add, insert, and remove Parameter objects using the appropriate methods of the ParameterCollection class. To programmatically retrieve Parameter objects from a collection, use one of following methods:

The Count property specifies the total number of items in the collection, and is used to determine the upper bound of the collection. You can add and remove items from the collection by using the Add, Insert, Remove, and RemoveAt methods.

Depending on the implementation and the semantics of a particular data source control, the order in which the parameters are stored in the ParameterCollection collection might be important. For example, when using the SqlDataSource control as an ODBC data source, the order of the Parameter objects in the ParameterCollection collection must be the same as the order of the parameters in the parameterized SQL queries you use. However, when using the SqlDataSource control with Microsoft SQL Server, the order of the Parameter objects are not important.

Security noteSecurity Note

When you use data source controls, values are inserted into command parameters without validation, which is a potential security threat. Use an event in the data source control to validate parameter values before the command is executed. For more information, see Script Exploits Overview.

The following table lists the different parameter classes and how they are used.

Parameter Class

Description

Parameter

The base parameter class. Use it to bind to a local variable or any static string using the DefaultValue property.

ControlParameter

A parameter that can be used to bind to a control's property or method return value.

CookieParameter

A parameter that can be used to bind to the value of a cookie.

FormParameter

A parameter that can be used to bind to an attribute of the current Web Forms page.

QueryStringParameter

A parameter that can be used to bind to a value passed to a Web Forms page on a query string.

SessionParameter

A parameter that can be used to bind to the value of a session variable.

ProfileParameter

A parameter that can be used to bind to the value of an ASP.NET Profile property.

The following code example demonstrates how to use an AccessDataSource control and a FormParameter to display information from a Microsoft Access database in a GridView control. The FormParameter object is added to the SelectParameters collection using the Add method.

Security noteSecurity Note

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

Visual Basic
<%@Page  Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Private Sub Page_Load(sender As Object, e As EventArgs)

  ' You can add a FormParameter to the AccessDataSource control's
  ' SelectParameters collection programmatically.
  AccessDataSource1.SelectParameters.Clear()

  ' Security Note: The AccessDataSource uses a FormParameter,
  ' Security Note: which does not perform validation of input from the client.
  ' Security Note: To validate the value of the FormParameter,
  ' Security Note: handle the Selecting event.

  Dim formParam As New FormParameter("lastname","LastNameBox")
  formParam.Type=TypeCode.String
  AccessDataSource1.SelectParameters.Add(formParam)
End Sub ' Page_Load

</script>
<html  >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <asp:accessdatasource
          id="AccessDataSource1"
          runat="server"
          datasourcemode="DataSet"
          datafile="Northwind.mdb"
          selectcommand="SELECT OrderID,CustomerID,OrderDate,RequiredDate,ShippedDate
                         FROM Orders WHERE EmployeeID =
                         (SELECT EmployeeID FROM Employees WHERE LastName = @lastname)">
      </asp:accessdatasource>

      <br />Enter the name "Davolio" or "King" in the text box and click the button.

      <br />
      <asp:textbox
        id="LastNameBox"
        runat="server" />

      <br />
      <asp:button
        id="Button1"
        runat="server"
        text="Get Records" />

      <br />
      <asp:gridview
          id="GridView1"
          runat="server"
          allowsorting="True"
          datasourceid="AccessDataSource1">
      </asp:gridview>

    </form>
  </body>
</html>
C#
<%@Page  Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

void Page_Load(Object sender, EventArgs e){

  // You can add a FormParameter to the AccessDataSource control's
  // SelectParameters collection programmatically.
  AccessDataSource1.SelectParameters.Clear();

  // Security Note: The AccessDataSource uses a FormParameter,
  // Security Note: which does not perform validation of input from the client.
  // Security Note: To validate the value of the FormParameter,
  // Security Note: handle the Selecting event.

  FormParameter formParam = new FormParameter("lastname","LastNameBox");
  formParam.Type=TypeCode.String;
  AccessDataSource1.SelectParameters.Add(formParam);
}

</script>
<html  >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <asp:accessdatasource
          id="AccessDataSource1"
          runat="server"
          datasourcemode="DataSet"
          datafile="Northwind.mdb"
          selectcommand="SELECT OrderID,CustomerID,OrderDate,RequiredDate,ShippedDate
                         FROM Orders WHERE EmployeeID =
                         (SELECT EmployeeID FROM Employees WHERE LastName = @lastname)">
      </asp:accessdatasource>

      <br />Enter the name "Davolio" or "King" in the text box and click the button.

      <br />
      <asp:textbox
        id="LastNameBox"
        runat="server" />

      <br />
      <asp:button
        id="Button1"
        runat="server"
        text="Get Records" />

      <br />
      <asp:gridview
          id="GridView1"
          runat="server"
          allowsorting="True"
          datasourceid="AccessDataSource1">
      </asp:gridview>

    </form>
  </body>
</html>

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, 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
ParameterCollection, classe

Représente une collection d'objets dérivés de Parameter et Parameter qui sont utilisés par les contrôles de source de données dans les scénarios de liaison de données avancés.

System..::.Object
  System.Web.UI..::.StateManagedCollection
    System.Web.UI.WebControls..::.ParameterCollection

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

Le type ParameterCollection expose les membres suivants.

  NomDescription
Méthode publiqueParameterCollectionInitialise la classe pour qu'elle soit utilisée par une instance de la classe héritée. Ce constructeur peut être appelé uniquement par une classe héritée.
Début
  NomDescription
Propriété publiqueCountObtient le nombre d'éléments contenus dans la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Propriété publiqueItem[([(Int32])])Obtient ou définit l'objet Parameter à l'index spécifié dans la collection.
Propriété publiqueItem[([(String])])Obtient ou définit l'objet Parameter portant le nom spécifié dans la collection.
Début
  NomDescription
Méthode publiqueAdd(Parameter)Ajoute l'objet Parameter spécifié à la fin de la collection.
Méthode publiqueAdd(String, String)Crée un objet Parameter avec le nom spécifié et la valeur par défaut et l'ajoute à la fin de la collection.
Méthode publiqueAdd(String, DbType, String)Crée un objet Parameter avec le nom, le type de base de données et la valeur par défaut spécifiés, puis l'ajoute à la fin de la collection.
Méthode publiqueAdd(String, TypeCode, String)Crée un objet Parameter avec le nom spécifié, TypeCode et la valeur par défaut et l'ajoute à la fin de la collection.
Méthode publiqueClearSupprime tous les éléments de la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Méthode publiqueContainsDétermine si la collection ParameterCollection contient une valeur spécifique.
Méthode publiqueCopyTo(Array, Int32)Copie les éléments de la collection StateManagedCollection dans un tableau, en commençant au niveau d'un index de tableau particulier. (Hérité de StateManagedCollection.)
Méthode publiqueCopyTo(array<Parameter>[]()[], Int32)Copie l'index spécifié d'un tableau de paramètres dans la collection de paramètres.
Méthode protégéeCreateKnownTypeCrée une instance d'un objet Parameter par défaut. (Substitue StateManagedCollection..::.CreateKnownType(Int32).)
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 publiqueGetEnumeratorRetourne un itérateur qui itère au sein de la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Méthode publiqueGetHashCodeSert de fonction de hachage pour un type particulier. (Hérité de Object.)
Méthode protégéeGetKnownTypesObtient un tableau des types Parameter que la collection ParameterCollection peut contenir. (Substitue StateManagedCollection..::.GetKnownTypes()()().)
Méthode publiqueGetTypeObtient le Type de l'instance actuelle. (Hérité de Object.)
Méthode publiqueGetValuesObtient une collection triée de noms d'objets Parameter et leurs valeurs correspondantes actuellement contenus dans la collection.
Méthode publiqueIndexOfDétermine l'index d'un objet Parameter spécifié dans la collection ParameterCollection.
Méthode publiqueInsertInsère l'objet Parameter spécifié dans la collection ParameterCollection à l'index spécifié.
Méthode protégéeMemberwiseCloneCrée une copie superficielle de l'objet Object actif. (Hérité de Object.)
Méthode protégéeOnClearEn cas de substitution dans une classe dérivée, exécute une tâche supplémentaire avant que la méthode Clear supprime tous les éléments de la collection. (Hérité de StateManagedCollection.)
Méthode protégéeOnClearCompleteExécute des processus personnalisés supplémentaires après l'effacement du contenu de la collection. (Substitue StateManagedCollection..::.OnClearComplete()()().)
Méthode protégéeOnInsertSe produit avant que la méthode Insert soit appelée. (Substitue StateManagedCollection..::.OnInsert(Int32, Object).)
Méthode protégéeOnInsertCompleteSe produit après que la méthode Insert est terminée. (Substitue StateManagedCollection..::.OnInsertComplete(Int32, Object).)
Méthode protégéeOnParametersChangedDéclenche l'événement ParametersChanged.
Méthode protégéeOnRemoveEn cas de substitution dans une classe dérivée, exécute toute tâche supplémentaire avant que la méthode Remove(Object) ou RemoveAt(Int32) supprime l'élément spécifié de la collection. (Hérité de StateManagedCollection.)
Méthode protégéeOnRemoveCompleteSe produit après que la méthode Remove est terminée. (Substitue StateManagedCollection..::.OnRemoveComplete(Int32, Object).)
Méthode protégéeOnValidateExécute des processus personnalisés supplémentaires lors de la validation d'une valeur. (Substitue StateManagedCollection..::.OnValidate(Object).)
Méthode publiqueRemoveSupprime de la collection ParameterCollection l'objet Parameter spécifié.
Méthode publiqueRemoveAtSupprime de la collection ParameterCollection l'objet Parameter à l'index spécifié.
Méthode publiqueSetDirtyForce la sérialisation de l'intégralité de la collection StateManagedCollection dans l'état d'affichage. (Hérité de StateManagedCollection.)
Méthode protégéeSetDirtyObjectMarque l'objet Parameter spécifié comme modifié depuis son dernier chargement ou enregistrement à partir de l'état d'affichage. (Substitue StateManagedCollection..::.SetDirtyObject(Object).)
Méthode publiqueToStringRetourne une chaîne qui représente l'objet actuel. (Hérité de Object.)
Méthode publiqueUpdateValuesItère au sein des objets Parameter contenus dans la collection et appelle la méthode Evaluate sur chacun des objets.
Début
  NomDescription
Événement publicParametersChangedSe produit lorsque l'état d'un ou de plusieurs objets Parameter contenus dans la collection est modifié.
Début
  NomDescription
Implémentation d'interface explicitePropriété privéeICollection..::.CountInfrastructure. Obtient le nombre d'éléments contenus dans la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeICollection..::.IsSynchronizedInfrastructure. Obtient une valeur indiquant si la collection StateManagedCollection est synchronisée (thread-safe). Cette méthode retourne false dans tous les cas. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeICollection..::.SyncRootInfrastructure. Obtient un objet qui peut être utilisé pour synchroniser l'accès à la collection StateManagedCollection. Cette méthode retourne nullNothingnullptrune référence null (Nothing en Visual Basic) dans tous les cas. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIEnumerable..::.GetEnumeratorInfrastructure. Retourne un itérateur qui itère au sein de la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.AddAjoute un élément à la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.ClearInfrastructure. Supprime tous les éléments de la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.ContainsDétermine si la collection StateManagedCollection contient une valeur spécifique. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.IndexOfDétermine l'index d'un élément spécifié de la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.InsertInsère un élément dans la collection StateManagedCollection à l'index spécifié. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeIList..::.IsFixedSizeInfrastructure. Obtient une valeur indiquant si la collection StateManagedCollection est de taille fixe. Cette méthode retourne false dans tous les cas. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeIList..::.IsReadOnlyInfrastructure. Obtient une valeur indiquant si la collection StateManagedCollection est en lecture seule. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeIList..::.ItemInfrastructure. Obtient l'élément IStateManager à l'index spécifié. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.RemoveSupprime la première occurrence de l'objet spécifié dans la collection StateManagedCollection. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIList..::.RemoveAtSupprime l'élément IStateManager au niveau de l'index spécifié. (Hérité de StateManagedCollection.)
Implémentation d'interface explicitePropriété privéeIStateManager..::.IsTrackingViewStateObtient une valeur indiquant si la collection StateManagedCollection enregistre les modifications apportées à son état d'affichage. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIStateManager..::.LoadViewStateRestaure l'état d'affichage précédemment enregistré de la collection StateManagedCollection et les éléments IStateManager qu'elle contient. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIStateManager..::.SaveViewStateEnregistre les modifications apportées à la collection StateManagedCollection et à chaque objet IStateManager qu'elle contient, depuis la publication de la page sur le serveur. (Hérité de StateManagedCollection.)
Implémentation d'interface expliciteMéthode privéeIStateManager..::.TrackViewStateCommande à la collection StateManagedCollection et à chacun des objets IStateManager qu'elle contient de procéder au suivi des modifications apportées à leur état d'affichage afin qu'ils puissent être rendus persistants au fil des requêtes d'une même page. (Hérité de StateManagedCollection.)
Début

La classe ParameterCollection représente une collection d'objets Parameter utilisée dans les scénarios de liaison de données avancés avec les contrôles de source de données. Les objets Parameter sont utilisés pour lier les valeurs contenues dans les variables Page locales, les cookies HTTP, les variables de session et d'autres valeurs de contrôles aux contrôles de source de données lors de la récupération, de la mise à jour, de la suppression et de l'insertion de données.

Utilisez la classe ParameterCollection pour gérer par programme un ensemble d'objets Parameter. Vous pouvez ajouter, insérer et supprimer des objets Parameter à l'aide des méthodes appropriées de la classe ParameterCollection. Pour récupérer par programme des objets Parameter à partir d'une collection, utilisez l'une des méthodes suivantes :

  • Utilisez l'indexeur pour obtenir un seul objet Parameter de la collection, par nom ou à l'aide d'une notation de tableau.

  • Utilisez la méthode GetEnumerator pour créer un objet implémentant System.Collections..::.IEnumerator, pouvant ensuite être utilisé pour obtenir des éléments de la collection.

La propriété Count spécifie le nombre total d'éléments dans la collection et est utilisée pour déterminer la limite supérieure de la collection. Vous pouvez ajouter des éléments dans la collection ou en supprimer à l'aide des méthodes Add, Insert, Remove et RemoveAt.

En fonction de l'implémentation et de la sémantique d'un contrôle de source de données particulier, il est possible que l'ordre dans lequel les paramètres sont stockés dans la collection ParameterCollection soit important. Par exemple, lors de l'utilisation du contrôle SqlDataSource comme source de données ODBC, l'ordre des objets Parameter dans la collection ParameterCollection doit être le même que l'ordre des paramètres dans les requêtes SQL paramétrées que vous utilisez. Toutefois, lors de l'utilisation du contrôle SqlDataSource avec Microsoft SQL Server, l'ordre des objets Parameter n'est pas important.

Note de sécuritéNote de sécurité

Lorsque vous utilisez des contrôles de source de données, les valeurs sont insérées dans des paramètres de commande sans validation, ce qui constitue une menace potentielle pour la sécurité. Utilisez un événement dans le contrôle de source de données pour valider les valeurs de paramètre avant l'exécution de la commande. Pour plus d'informations, consultez Vue d'ensemble des attaques de script.

Le tableau suivant répertorie les différentes classes Parameter et comment elles sont utilisées.

Classe Parameter

Description

Parameter

Classe Parameter de base. Utilisez-la pour créer une liaison avec une variable locale ou toute chaîne statique à l'aide de la propriété DefaultValue.

ControlParameter

Paramètre qui peut être utilisé pour créer une liaison avec une valeur de retour de méthode ou de propriété d'un contrôle.

CookieParameter

Paramètre qui peut être utilisé pour créer une liaison avec la valeur d'un cookie.

FormParameter

Paramètre qui peut être utilisé pour créer une liaison avec un attribut de la page Web Forms en cours.

QueryStringParameter

Paramètre qui peut être utilisé pour créer une liaison avec une valeur passée à une page Web Forms sur une chaîne de requête.

SessionParameter

Paramètre qui peut être utilisé pour créer une liaison avec la valeur d'une variable de session.

ProfileParameter

Paramètre qui peut être utilisé pour créer une liaison avec la valeur d'une propriété de profil ASP.NET.

L'exemple de code suivant montre comment utiliser un contrôle AccessDataSource et un FormParameter pour afficher des informations à partir d'une base de données Microsoft Access dans un contrôle GridView. L'objet FormParameter est ajouté à la collection SelectParameters à l'aide de la méthode Add.

Note de sécuritéNote de sécurité

Cet exemple a une zone de texte qui accepte l'entrée d'utilisateur, ce qui constitue une menace éventuelle pour la sécurité. Par défaut, les pages Web ASP.NET vérifient que l'entrée d'utilisateur n'inclut pas de script ni d'éléments HTML. Pour plus d'informations, consultez Vue d'ensemble des attaques de script.

Visual Basic
<%@Page  Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Private Sub Page_Load(sender As Object, e As EventArgs)

  ' You can add a FormParameter to the AccessDataSource control's
  ' SelectParameters collection programmatically.
  AccessDataSource1.SelectParameters.Clear()

  ' Security Note: The AccessDataSource uses a FormParameter,
  ' Security Note: which does not perform validation of input from the client.
  ' Security Note: To validate the value of the FormParameter,
  ' Security Note: handle the Selecting event.

  Dim formParam As New FormParameter("lastname","LastNameBox")
  formParam.Type=TypeCode.String
  AccessDataSource1.SelectParameters.Add(formParam)
End Sub ' Page_Load

</script>
<html  >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <asp:accessdatasource
          id="AccessDataSource1"
          runat="server"
          datasourcemode="DataSet"
          datafile="Northwind.mdb"
          selectcommand="SELECT OrderID,CustomerID,OrderDate,RequiredDate,ShippedDate
                         FROM Orders WHERE EmployeeID =
                         (SELECT EmployeeID FROM Employees WHERE LastName = @lastname)">
      </asp:accessdatasource>

      <br />Enter the name "Davolio" or "King" in the text box and click the button.

      <br />
      <asp:textbox
        id="LastNameBox"
        runat="server" />

      <br />
      <asp:button
        id="Button1"
        runat="server"
        text="Get Records" />

      <br />
      <asp:gridview
          id="GridView1"
          runat="server"
          allowsorting="True"
          datasourceid="AccessDataSource1">
      </asp:gridview>

    </form>
  </body>
</html>
C#
<%@Page  Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

void Page_Load(Object sender, EventArgs e){

  // You can add a FormParameter to the AccessDataSource control's
  // SelectParameters collection programmatically.
  AccessDataSource1.SelectParameters.Clear();

  // Security Note: The AccessDataSource uses a FormParameter,
  // Security Note: which does not perform validation of input from the client.
  // Security Note: To validate the value of the FormParameter,
  // Security Note: handle the Selecting event.

  FormParameter formParam = new FormParameter("lastname","LastNameBox");
  formParam.Type=TypeCode.String;
  AccessDataSource1.SelectParameters.Add(formParam);
}

</script>
<html  >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <asp:accessdatasource
          id="AccessDataSource1"
          runat="server"
          datasourcemode="DataSet"
          datafile="Northwind.mdb"
          selectcommand="SELECT OrderID,CustomerID,OrderDate,RequiredDate,ShippedDate
                         FROM Orders WHERE EmployeeID =
                         (SELECT EmployeeID FROM Employees WHERE LastName = @lastname)">
      </asp:accessdatasource>

      <br />Enter the name "Davolio" or "King" in the text box and click the button.

      <br />
      <asp:textbox
        id="LastNameBox"
        runat="server" />

      <br />
      <asp:button
        id="Button1"
        runat="server"
        text="Get Records" />

      <br />
      <asp:gridview
          id="GridView1"
          runat="server"
          allowsorting="True"
          datasourceid="AccessDataSource1">
      </asp:gridview>

    </form>
  </body>
</html>

.NET Framework

Pris en charge dans : 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, 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