次の方法で共有


FormParameter コンストラクター

定義

FormParameter クラスの新しいインスタンスを初期化します。

オーバーロード

名前 説明
FormParameter()

FormParameter クラスの新しい名前のないインスタンスを初期化します。

FormParameter(FormParameter)

original パラメーターで指定されたインスタンスの値を使用して、FormParameter クラスの新しいインスタンスを初期化します。

FormParameter(String, String)

バインド先のフォーム変数フィールドを識別するために、指定した文字列を使用して、 FormParameter クラスの新しい名前付きインスタンスを初期化します。

FormParameter(String, DbType, String)

バインド先のフォーム変数フィールドを識別するために、指定した文字列を使用して、 FormParameter クラスの新しいインスタンスを初期化します。

FormParameter(String, TypeCode, String)

バインド先のフォーム変数を識別するために、指定した文字列を使用して、 FormParameter クラスの新しい名前付きの厳密に型指定されたインスタンスを初期化します。

FormParameter()

FormParameter クラスの新しい名前のないインスタンスを初期化します。

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

Important

FormParameterは、フォーム要素によって渡された値を検証しません。生の値を使用します。 ほとんどの場合、使用しているデータ ソース コントロールによって公開されるSelectingUpdatingInsertingDeleting イベントなどのイベントを処理することで、データ ソース コントロールによって使用される前にFormParameterの値を検証できます。 パラメーターの値が検証テストに合格しない場合は、関連付けられているCancelEventArgs クラスの Cancel プロパティを 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>

注釈

FormParameter コンストラクターで作成されたFormParameter オブジェクトは、そのすべてのプロパティの既定値で初期化されます。 FormFieldは、String.Emptyに初期化されます。 さらに、 Name プロパティは String.Emptyに初期化され、 Type プロパティは TypeCode.Objectに初期化され、 Direction プロパティは Inputに初期化され、 DefaultValue プロパティは null (Visual Basic ではNothing ) に初期化されます。

こちらもご覧ください

適用対象

FormParameter(FormParameter)

original パラメーターで指定されたインスタンスの値を使用して、FormParameter クラスの新しいインスタンスを初期化します。

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)

パラメーター

original
FormParameter

現在のインスタンスが初期化される FormParameter インスタンス。

注釈

FormParameter コンストラクターは、FormParameter インスタンスの複製に使用されるprotectedコピー コンストラクターです。 FormFieldNameTypeなど、FormParameterの値はすべて新しいインスタンスに転送されます。

こちらもご覧ください

適用対象

FormParameter(String, String)

バインド先のフォーム変数フィールドを識別するために、指定した文字列を使用して、 FormParameter クラスの新しい名前付きインスタンスを初期化します。

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)

パラメーター

name
String

パラメーターの名前。

formField
String

パラメーター オブジェクトがバインドされているフォーム変数の名前。 既定値は、Empty です。

Important

FormParameterは、フォーム要素によって渡された値を検証しません。生の値を使用します。 ほとんどの場合、使用しているデータ ソース コントロールによって公開されるSelectingUpdatingInsertingDeleting イベントなどのイベントを処理することで、データ ソース コントロールによって使用される前にFormParameterの値を検証できます。 パラメーターの値が検証テストに合格しない場合は、関連付けられているCancelEventArgs クラスの Cancel プロパティを 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>

注釈

FormParameter コンストラクターで作成されたFormParameter オブジェクトは、指定されたパラメーター名と、パラメーターがバインドするフォーム変数を識別する文字列で初期化されます。 TypeプロパティとDirection プロパティは既定値で初期化されます。

こちらもご覧ください

適用対象

FormParameter(String, DbType, String)

バインド先のフォーム変数フィールドを識別するために、指定した文字列を使用して、 FormParameter クラスの新しいインスタンスを初期化します。

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)

パラメーター

name
String

パラメーターの名前。

dbType
DbType

パラメーターのデータベース型。

formField
String

パラメーター オブジェクトがバインドされているフォーム変数の名前。

適用対象

FormParameter(String, TypeCode, String)

バインド先のフォーム変数を識別するために、指定した文字列を使用して、 FormParameter クラスの新しい名前付きの厳密に型指定されたインスタンスを初期化します。

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)

パラメーター

name
String

パラメーターの名前。

type
TypeCode

パラメーターが表す型。 既定値は、Object です。

formField
String

パラメーター オブジェクトがバインドされているフォーム変数の名前。 既定値は、Empty です。

Important

FormParameterは、フォーム要素によって渡された値を検証しません。生の値を使用します。 ほとんどの場合、使用しているデータ ソース コントロールによって公開されるSelectingUpdatingInsertingDeleting イベントなどのイベントを処理することで、データ ソース コントロールによって使用される前にFormParameterの値を検証できます。 パラメーターの値が検証テストに合格しない場合は、関連付けられているCancelEventArgs クラスの Cancel プロパティを 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>

注釈

FormParameter コンストラクターで作成されたFormParameter オブジェクトは、パラメーターがバインドされるフォーム変数を識別する、指定されたパラメーター名、Type、および文字列で初期化されます。 既定値で初期化されるのは、 Direction プロパティと ConvertEmptyStringToNull プロパティだけです。

こちらもご覧ください

適用対象