Condividi tramite


FormParameter Costruttori

Definizione

Inizializza una nuova istanza della classe FormParameter.

Overload

Nome Descrizione
FormParameter()

Inizializza una nuova istanza senza nome della FormParameter classe .

FormParameter(FormParameter)

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

FormParameter(String, String)

Inizializza una nuova istanza denominata della FormParameter classe utilizzando la stringa specificata per identificare il campo della variabile di modulo a cui eseguire l'associazione.

FormParameter(String, DbType, String)

Inizializza una nuova istanza della FormParameter classe utilizzando la stringa specificata per identificare il campo della variabile di modulo a cui eseguire l'associazione.

FormParameter(String, TypeCode, String)

Inizializza una nuova istanza denominata e fortemente tipizzata della FormParameter classe utilizzando la stringa specificata per identificare la variabile di modulo a cui eseguire l'associazione.

FormParameter()

Inizializza una nuova istanza senza nome della FormParameter classe .

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

Esempio

Importante

Non FormParameter convalida il valore passato dall'elemento form in alcun modo, ma utilizza il valore non elaborato. Nella maggior parte dei casi, è possibile convalidare il valore di prima che FormParameter venga usato da un controllo origine dati gestendo un evento, ad esempio l'evento Selecting, Updating, Insertingo Deleting 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 i valori predefiniti per tutte le relative proprietà. L'oggetto FormField viene inizializzato in String.Empty. Inoltre, la Name proprietà viene inizializzata in String.Empty, la Type proprietà viene inizializzata su TypeCode.Object, la Direction proprietà viene inizializzata su Inpute la DefaultValue proprietà viene inizializzata su null (Nothing in Visual Basic).

Vedi anche

Si applica a

FormParameter(FormParameter)

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

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

FormParameter Istanza da cui viene inizializzata l'istanza corrente.

Commenti

Il FormParameter costruttore è un protected costruttore di copia usato per clonare un'istanza FormParameter di . 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 FormParameter classe utilizzando la stringa specificata per identificare il campo della variabile di modulo a cui eseguire 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 modulo a cui è associato l'oggetto parametro. Il valore predefinito è Empty.

Esempio

Importante

Non FormParameter convalida il valore passato dall'elemento form in alcun modo, ma utilizza il valore non elaborato. Nella maggior parte dei casi, è possibile convalidare il valore di prima che FormParameter venga usato da un controllo origine dati gestendo un evento, ad esempio l'evento Selecting, Updating, Insertingo Deleting 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 del parametro e la stringa specificati che identifica la variabile di modulo a cui il parametro è associato. Le Type proprietà e Direction vengono inizializzate con i valori predefiniti.

Vedi anche

Si applica a

FormParameter(String, DbType, String)

Inizializza una nuova istanza della FormParameter classe utilizzando la stringa specificata per identificare il campo della variabile di modulo a cui eseguire 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 modulo a cui è associato l'oggetto parametro.

Si applica a

FormParameter(String, TypeCode, String)

Inizializza una nuova istanza denominata e fortemente tipizzata della FormParameter classe utilizzando la stringa specificata per identificare la variabile di modulo a cui eseguire 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 modulo a cui è associato l'oggetto parametro. Il valore predefinito è Empty.

Esempio

Importante

Non FormParameter convalida il valore passato dall'elemento form in alcun modo, ma utilizza il valore non elaborato. Nella maggior parte dei casi, è possibile convalidare il valore di prima che FormParameter venga usato da un controllo origine dati gestendo un evento, ad esempio l'evento Selecting, Updating, Insertingo Deleting 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, Typee la stringa specificati che identifica la variabile di modulo a cui il parametro è associato. Solo le Direction proprietà e ConvertEmptyStringToNull vengono inizializzate con valori predefiniti.

Vedi anche

Si applica a