FormParameter Constructores

Definición

Inicializa una nueva instancia de la clase FormParameter.Initializes a new instance of the FormParameter class.

Sobrecargas

FormParameter()

Inicializa una nueva instancia sin nombre de la clase FormParameter.Initializes a new unnamed instance of the FormParameter class.

FormParameter(FormParameter)

Inicializa una nueva instancia de la clase FormParameter con los valores de la instancia que especifica el parámetro original.Initializes a new instance of the FormParameter class with the values of the instance specified by the original parameter.

FormParameter(String, String)

Inicializa una nueva instancia con nombre de la clase FormParameter, utilizando la cadena especificada para identificar a qué campo de variable de formulario se va a enlazar.Initializes a new named instance of the FormParameter class, using the specified string to identify which form variable field to bind to.

FormParameter(String, DbType, String)

Inicializa una nueva instancia de la clase FormParameter, utilizando la cadena especificada para identificar a qué campo de variable de formulario se va a enlazar.Initializes a new instance of the FormParameter class, using the specified string to identify which form variable field to bind to.

FormParameter(String, TypeCode, String)

Inicializa una nueva instancia fuertemente tipada de la clase FormParameter, utilizando la cadena especificada para identificar a qué variable de formulario se va a enlazar.Initializes a new named and strongly typed instance of the FormParameter class, using the specified string to identify which form variable to bind to.

FormParameter()

Inicializa una nueva instancia sin nombre de la clase FormParameter.Initializes a new unnamed instance of the FormParameter class.

public:
 FormParameter();
public FormParameter ();
Public Sub New ()

Ejemplos

Importante

No FormParameter valida el valor pasado por el elemento form de ninguna manera; utiliza el valor sin formato.The FormParameter does not validate the value passed by the form element in any way; it uses the raw value. En la mayoría de los casos, puede validar el valor de FormParameter antes de que lo use un control de origen de datos controlando un evento, como el Selecting Updating evento,, Inserting o Deleting expuesto por el control de origen de datos que está utilizando.In most cases, you can validate the value of the FormParameter before it is used by a data source control by handling an event, such as the Selecting, Updating, Inserting, or Deleting event exposed by the data source control you are using. Si el valor del parámetro no pasa las pruebas de validación, puede cancelar la operación de datos estableciendo la Cancel propiedad de la CancelEventArgs clase asociada en true .If the value of the parameter does not pass your validation tests, you can cancel the data operation by setting the Cancel property of the associated CancelEventArgs class to true.

<%@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();
  formParam.Name="lastname";
  formParam.Type=TypeCode.String;
  formParam.FormField="LastNameBox";
  AccessDataSource1.SelectParameters.Add(formParam);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <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" />

    </form>
  </body>
</html>
<%@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()
  formParam.Name="lastname"
  formParam.Type=TypeCode.String
  formParam.FormField="LastNameBox"
  AccessDataSource1.SelectParameters.Add(formParam)

End Sub ' Page_Load

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <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" />

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

Comentarios

Un FormParameter objeto creado con el FormParameter constructor se inicializa con los valores predeterminados para todas sus propiedades.A FormParameter object created with the FormParameter constructor is initialized with default values for all its properties. FormFieldSe inicializa en String.Empty .The FormField is initialized to String.Empty. Además, la Name propiedad se inicializa en String.Empty , la Type propiedad se inicializa en TypeCode.Object , la Direction propiedad se inicializa en Input y la DefaultValue propiedad se inicializa en null ( Nothing en Visual Basic).Additionally, the Name property is initialized to String.Empty, the Type property is initialized to TypeCode.Object, the Direction property is initialized to Input, and the DefaultValue property is initialized to null (Nothing in Visual Basic).

Consulte también

Se aplica a

FormParameter(FormParameter)

Inicializa una nueva instancia de la clase FormParameter con los valores de la instancia que especifica el parámetro original.Initializes a new instance of the FormParameter class with the values of the instance specified by the original parameter.

protected:
 FormParameter(System::Web::UI::WebControls::FormParameter ^ original);
protected FormParameter (System.Web.UI.WebControls.FormParameter original);
new System.Web.UI.WebControls.FormParameter : System.Web.UI.WebControls.FormParameter -> System.Web.UI.WebControls.FormParameter
Protected Sub New (original As FormParameter)

Parámetros

original
FormParameter

Instancia FormParameter desde la que se inicializa la instancia actual.A FormParameter instance that the current instance is initialized from.

Comentarios

El FormParameter constructor es un protected constructor de copias utilizado para clonar una FormParameter instancia de.The FormParameter constructor is a protected copy constructor used to clone a FormParameter instance. Los valores de FormParameter , incluidos FormField , Name y, Type se transfieren a la nueva instancia.The values of the FormParameter, including FormField, Name, and Type are all transferred to the new instance.

Consulte también

Se aplica a

FormParameter(String, String)

Inicializa una nueva instancia con nombre de la clase FormParameter, utilizando la cadena especificada para identificar a qué campo de variable de formulario se va a enlazar.Initializes a new named instance of the FormParameter class, using the specified string to identify which form variable field to bind to.

public:
 FormParameter(System::String ^ name, System::String ^ formField);
public FormParameter (string name, string formField);
new System.Web.UI.WebControls.FormParameter : string * string -> System.Web.UI.WebControls.FormParameter
Public Sub New (name As String, formField As String)

Parámetros

name
String

El nombre del parámetro.The name of the parameter.

formField
String

Nombre de la variable de formulario a la que se enlaza el objeto de parámetro.The name of the form variable that the parameter object is bound to. El valor predeterminado es Empty.The default is Empty.

Ejemplos

Importante

No FormParameter valida el valor pasado por el elemento form de ninguna manera; utiliza el valor sin formato.The FormParameter does not validate the value passed by the form element in any way; it uses the raw value. En la mayoría de los casos, puede validar el valor de FormParameter antes de que lo use un control de origen de datos controlando un evento, como el Selecting Updating evento,, Inserting o Deleting expuesto por el control de origen de datos que está utilizando.In most cases, you can validate the value of the FormParameter before it is used by a data source control by handling an event, such as the Selecting, Updating, Inserting, or Deleting event exposed by the data source control you are using. Si el valor del parámetro no pasa las pruebas de validación, puede cancelar la operación de datos estableciendo la Cancel propiedad de la CancelEventArgs clase asociada en true .If the value of the parameter does not pass your validation tests, you can cancel the data operation by setting the Cancel property of the associated CancelEventArgs class to true.

<%@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 xmlns="http://www.w3.org/1999/xhtml" >
  <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>
<%@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 xmlns="http://www.w3.org/1999/xhtml" >
  <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>

Comentarios

Un FormParameter objeto creado con el FormParameter constructor se inicializa con el nombre de parámetro y la cadena especificados que identifica la variable de formulario a la que se enlaza el parámetro.A FormParameter object created with the FormParameter constructor is initialized with the specified parameter name and string that identifies the form variable that the parameter binds to. Las Type Direction propiedades y se inicializan con los valores predeterminados.The Type and Direction properties are initialized with default values.

Consulte también

Se aplica a

FormParameter(String, DbType, String)

Inicializa una nueva instancia de la clase FormParameter, utilizando la cadena especificada para identificar a qué campo de variable de formulario se va a enlazar.Initializes a new instance of the FormParameter class, using the specified string to identify which form variable field to bind to.

public:
 FormParameter(System::String ^ name, System::Data::DbType dbType, System::String ^ formField);
public FormParameter (string name, System.Data.DbType dbType, string formField);
new System.Web.UI.WebControls.FormParameter : string * System.Data.DbType * string -> System.Web.UI.WebControls.FormParameter
Public Sub New (name As String, dbType As DbType, formField As String)

Parámetros

name
String

El nombre del parámetro.The name of the parameter.

dbType
DbType

Tipo de base de datos del parámetro.The database type of the parameter.

formField
String

Nombre de la variable de formulario a la que se enlaza el objeto de parámetro.The name of the form variable that the parameter object is bound to.

Se aplica a

FormParameter(String, TypeCode, String)

Inicializa una nueva instancia fuertemente tipada de la clase FormParameter, utilizando la cadena especificada para identificar a qué variable de formulario se va a enlazar.Initializes a new named and strongly typed instance of the FormParameter class, using the specified string to identify which form variable to bind to.

public:
 FormParameter(System::String ^ name, TypeCode type, System::String ^ formField);
public FormParameter (string name, TypeCode type, string formField);
new System.Web.UI.WebControls.FormParameter : string * TypeCode * string -> System.Web.UI.WebControls.FormParameter
Public Sub New (name As String, type As TypeCode, formField As String)

Parámetros

name
String

El nombre del parámetro.The name of the parameter.

type
TypeCode

Tipo que el parámetro representa.The type that the parameter represents. El valor predeterminado es Object.The default is Object.

formField
String

Nombre de la variable de formulario a la que se enlaza el objeto de parámetro.The name of the form variable that the parameter object is bound to. El valor predeterminado es Empty.The default is Empty.

Ejemplos

Importante

No FormParameter valida el valor pasado por el elemento form de ninguna manera; utiliza el valor sin formato.The FormParameter does not validate the value passed by the form element in any way; it uses the raw value. En la mayoría de los casos, puede validar el valor de FormParameter antes de que lo use un control de origen de datos controlando un evento, como el Selecting Updating evento,, Inserting o Deleting expuesto por el control de origen de datos que está utilizando.In most cases, you can validate the value of the FormParameter before it is used by a data source control by handling an event, such as the Selecting, Updating, Inserting, or Deleting event exposed by the data source control you are using. Si el valor del parámetro no pasa las pruebas de validación, puede cancelar la operación de datos estableciendo la Cancel propiedad de la CancelEventArgs clase asociada en true .If the value of the parameter does not pass your validation tests, you can cancel the data operation by setting the Cancel property of the associated CancelEventArgs class to true.

<%@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", TypeCode.String, "LastNameBox");
  AccessDataSource1.SelectParameters.Add(formParam);
}

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <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>
<%@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",TypeCode.String,"LastNameBox")
  AccessDataSource1.SelectParameters.Add(formParam)

End Sub ' Page_Load

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <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>

Comentarios

Un FormParameter objeto creado con el FormParameter constructor se inicializa con el nombre de parámetro, Type , y cadena especificados que identifica la variable de formulario a la que se enlaza el parámetro.A FormParameter object created with the FormParameter constructor is initialized with the specified parameter name, Type, and string that identifies the form variable that the parameter binds to. Solo las Direction ConvertEmptyStringToNull propiedades y se inicializan con los valores predeterminados.Only the Direction and ConvertEmptyStringToNull properties are initialized with default values.

Consulte también

Se aplica a