FormParameter Costruttori

Definizione

Inizializza una nuova istanza della classe FormParameter.

Overload

FormParameter()

Inizializza una nuova istanza senza nome della classe FormParameter.

FormParameter(FormParameter)

Inizializza una nuova istanza della classe FormParameter con i valori dell'istanza specificata dal parametro original.

FormParameter(String, String)

Inizializza una nuova istanza denominata della classe FormParameter, utilizzando la stringa specificata per identificare il campo della variabile di form per l'associazione.

FormParameter(String, DbType, String)

Inizializza una nuova istanza della classe FormParameter, utilizzando la stringa specificata per identificare il campo della variabile di form per l'associazione.

FormParameter(String, TypeCode, String)

Inizializza una nuova istanza denominata e fortemente tipizzata della classe FormParameter, utilizzando la stringa specificata per identificare la variabile di form per l'associazione.

FormParameter()

Inizializza una nuova istanza senza nome della classe FormParameter.

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

Esempio

Importante

Il FormParameter valore non convalida il valore passato dall'elemento form in alcun modo; usa il valore non elaborato. Nella maggior parte dei casi, è possibile convalidare il valore dell'oggetto prima che FormParameter venga usato da un controllo origine dati gestendo un evento, ad esempio , SelectingUpdating, Insertingo Deleting evento esposto dal controllo origine dati in uso. Se il valore del parametro non supera i test di convalida, è possibile annullare l'operazione di dati impostando la Cancel proprietà della classe associata CancelEventArgs su 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>

Commenti

Un FormParameter oggetto creato con il FormParameter costruttore viene inizializzato con valori predefiniti per tutte le relative proprietà. Viene FormField inizializzato in String.Empty. Inoltre, la Name proprietà viene inizializzata String.Emptyin , la Type proprietà viene inizializzata in TypeCode.Object, la Direction proprietà viene inizializzata in e la DefaultValue proprietà viene inizializzata su InputNull (Nothing in Visual Basic).

Vedi anche

Si applica a

FormParameter(FormParameter)

Inizializza una nuova istanza della classe FormParameter con i valori dell'istanza specificata dal parametro original.

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)

Parametri

original
FormParameter

Istanza FormParameter da cui viene inizializzata l'istanza corrente.

Commenti

Il costruttore è un costruttore di copia usato per clonare un'istanza FormParameterprotectedFormParameter . I valori di FormParameter, inclusi FormField, Namee Type vengono tutti trasferiti alla nuova istanza.

Vedi anche

Si applica a

FormParameter(String, String)

Inizializza una nuova istanza denominata della classe FormParameter, utilizzando la stringa specificata per identificare il campo della variabile di form per l'associazione.

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)

Parametri

name
String

Nome del parametro.

formField
String

Nome della variabile di form a cui è associato l'oggetto Parameter. Il valore predefinito è Empty.

Esempio

Importante

Il FormParameter valore non convalida il valore passato dall'elemento form in alcun modo; usa il valore non elaborato. Nella maggior parte dei casi, è possibile convalidare il valore dell'oggetto prima che FormParameter venga usato da un controllo origine dati gestendo un evento, ad esempio , SelectingUpdating, Insertingo Deleting evento esposto dal controllo origine dati in uso. Se il valore del parametro non supera i test di convalida, è possibile annullare l'operazione di dati impostando la Cancel proprietà della classe associata CancelEventArgs su 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>

Commenti

Un FormParameter oggetto creato con il FormParameter costruttore viene inizializzato con il nome e la stringa di parametro specificati che identifica la variabile di modulo a cui viene associato il parametro. Le Type proprietà e Direction vengono inizializzate con valori predefiniti.

Vedi anche

Si applica a

FormParameter(String, DbType, String)

Inizializza una nuova istanza della classe FormParameter, utilizzando la stringa specificata per identificare il campo della variabile di form per l'associazione.

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)

Parametri

name
String

Nome del parametro.

dbType
DbType

Tipo di database del parametro.

formField
String

Nome della variabile di form a cui è associato l'oggetto Parameter.

Si applica a

FormParameter(String, TypeCode, String)

Inizializza una nuova istanza denominata e fortemente tipizzata della classe FormParameter, utilizzando la stringa specificata per identificare la variabile di form per l'associazione.

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)

Parametri

name
String

Nome del parametro.

type
TypeCode

Tipo rappresentato dal parametro. Il valore predefinito è Object.

formField
String

Nome della variabile di form a cui è associato l'oggetto Parameter. Il valore predefinito è Empty.

Esempio

Importante

Il FormParameter valore non convalida il valore passato dall'elemento form in alcun modo; usa il valore non elaborato. Nella maggior parte dei casi, è possibile convalidare il valore dell'oggetto prima che FormParameter venga usato da un controllo origine dati gestendo un evento, ad esempio , SelectingUpdating, Insertingo Deleting evento esposto dal controllo origine dati in uso. Se il valore del parametro non supera i test di convalida, è possibile annullare l'operazione di dati impostando la Cancel proprietà della classe associata CancelEventArgs su 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>

Commenti

Un FormParameter oggetto creato con il FormParameter costruttore viene inizializzato con il nome del parametro specificato, Typee la stringa che identifica la variabile di modulo a cui viene associato il parametro. Vengono inizializzate solo le Direction proprietà e ConvertEmptyStringToNull con i valori predefiniti.

Vedi anche

Si applica a