ControlParameter コンストラクター

定義

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

オーバーロード

ControlParameter()

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

ControlParameter(ControlParameter)

指定したインスタンスの値を使用して、ControlParameter クラスの新しいインスタンスを初期化します。

ControlParameter(String, String)

バインド先のコントロールを識別する指定されたコントロール名を使用して、ControlParameter クラスの名前付きの新しいインスタンスを初期化します。

ControlParameter(String, String, String)

指定されたプロパティ名およびバインド先のコントロールを識別するコントロール名を使用して、ControlParameter クラスの名前付きの新しいインスタンスを初期化します。

ControlParameter(String, DbType, String, String)

指定したパラメーター名、データベース型、コントロール ID、およびプロパティ名を使用して、ControlParameter クラスの新しいインスタンスを初期化します。

ControlParameter(String, TypeCode, String, String)

指定されたプロパティ名およびバインド先のコントロールを識別するコントロール名を使用して、ControlParameter クラスの厳密に型指定された名前付きの新しいインスタンスを初期化します。

ControlParameter()

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

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

次のコードは、 コンストラクターを使用して オブジェクトを ControlParameter 作成する方法を ControlParameter 示しています。 オブジェクトは ControlParameter 、コントロールの SelectedValue プロパティを DropDownList 、コントロールに表示されるデータを取得するパラメーター化された SQL クエリに DataGrid バインドします。

<%@ Page Language="C#" CodeFile="param1acs.aspx.cs" Inherits="param1acs_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList
          runat="server"
          AutoPostBack="True"
          id="DropDownList1">
            <asp:ListItem Value="USA">USA</asp:ListItem>
            <asp:ListItem Value="UK">UK</asp:ListItem>
         </asp:DropDownList>

        <asp:DataGrid
          runat="server"
          id="DataGrid1" />    
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="param1avb.aspx.vb" Inherits="param1avb_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList
          runat="server"
          AutoPostBack="True"
          id="DropDownList1">
            <asp:ListItem Value="USA">USA</asp:ListItem>
            <asp:ListItem Value="UK">UK</asp:ListItem>
         </asp:DropDownList>

        <asp:DataGrid
          runat="server"
          id="DataGrid1" />    
    </div>
    </form>
</body>
</html>

注釈

ControlParameterコンストラクターを使用してControlParameter作成されたオブジェクトは、そのすべてのプロパティの既定値で初期化されます。 ControlIDプロパティと PropertyName プロパティは にString.Empty初期化されます。 さらに、 Name プロパティは にString.Empty初期化され、 Type プロパティは にTypeCode.Object初期化され、 Direction プロパティは にInputnull初期化されますDefaultValue

適用対象

ControlParameter(ControlParameter)

指定したインスタンスの値を使用して、ControlParameter クラスの新しいインスタンスを初期化します。

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

パラメーター

original
ControlParameter

現在のインスタンスの初期化の基になる ControlParameter インスタンス。

注釈

コンストラクターは ControlParameter 、インスタンスの複製に使用される保護されたコピー コンストラクターです ControlParameter 。 、および Type の各プロパティを含むオブジェクトの NameControlParameterControlIDPropertyName値はすべて、新しいインスタンスに転送されます。

こちらもご覧ください

適用対象

ControlParameter(String, String)

バインド先のコントロールを識別する指定されたコントロール名を使用して、ControlParameter クラスの名前付きの新しいインスタンスを初期化します。

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

パラメーター

name
String

パラメーターの名前。

controlID
String

パラメーターのバインド先のコントロールの名前。 既定値は、Empty です。

注釈

ControlParameterコンストラクターを使用してControlParameter作成されたオブジェクトは、指定したパラメーター名とControl名前で初期化され、パラメーターがバインドされる をControl識別します。 、、、 DirectionなどのPropertyNameTypeその他のプロパティは、既定値で初期化されます。

こちらもご覧ください

適用対象

ControlParameter(String, String, String)

指定されたプロパティ名およびバインド先のコントロールを識別するコントロール名を使用して、ControlParameter クラスの名前付きの新しいインスタンスを初期化します。

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

パラメーター

name
String

パラメーターの名前。

controlID
String

パラメーターのバインド先のコントロールの名前。 既定値は、Empty です。

propertyName
String

パラメーターのバインド先のコントロールのプロパティの名前。 既定値は、Empty です。

次のコードは、 コンストラクターを使用してオブジェクトを作成 ControlParameter する方法を ControlParameter 示しています。 パラメーターは、 および DropDownList コントロールのTextBox値にバインドされ、Web Forms ページからデータベースにデータを入力します。

private void Button1_Click(object sender, EventArgs e) {

    // The user has pressed the Submit button, prepare a parameterized
    // SQL query to insert the values from the controls.
    AccessDataSource1.InsertCommand =
    "INSERT INTO Employees (FirstName,LastName,Address,City,PostalCode,Country,ReportsTo) " +
    "  VALUES (?,?,?,?,?,?,? ); ";

    AccessDataSource1.InsertParameters.Add(
      new ControlParameter("FirstName", "TextBox1", "Text"));

    AccessDataSource1.InsertParameters.Add(
      new ControlParameter("LastName", "TextBox2", "Text"));

    AccessDataSource1.InsertParameters.Add(
      new ControlParameter("Address", "TextBox3", "Text"));

    AccessDataSource1.InsertParameters.Add(
      new ControlParameter("City", "TextBox4", "Text"));

    AccessDataSource1.InsertParameters.Add(
      new ControlParameter("PostalCode", "TextBox5", "Text"));

    AccessDataSource1.InsertParameters.Add(
      new ControlParameter("Country", "TextBox6", "Text"));

    AccessDataSource1.InsertParameters.Add(
      new ControlParameter("ReportsTo", "DropDownList1", "SelectedValue"));

    try {
        AccessDataSource1.Insert();
    }
    finally {
        Button1.Visible = false;
        Label9.Visible = true;
    }
}
Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

    ' The user has pressed the Submit button, prepare a parameterized
    ' SQL query to insert the values from the controls.
    AccessDataSource1.InsertCommand = _
    "INSERT INTO Employees (FirstName,LastName,Address,City,PostalCode,Country,ReportsTo) " & _
    "  VALUES (?,?,?,?,?,?,? ); "

    Dim firstName As New ControlParameter("FirstName", "TextBox1", "Text")
    AccessDataSource1.InsertParameters.Add(firstName)

    Dim lastName As New ControlParameter("LastName", "TextBox2", "Text")
    AccessDataSource1.InsertParameters.Add(lastName)

    Dim address As New ControlParameter("Address", "TextBox3", "Text")
    AccessDataSource1.InsertParameters.Add(address)

    Dim city As New ControlParameter("City", "TextBox4", "Text")
    AccessDataSource1.InsertParameters.Add(city)

    Dim postalCode As New ControlParameter("PostalCode", "TextBox5", "Text")
    AccessDataSource1.InsertParameters.Add(postalCode)

    Dim country As New ControlParameter("Country", "TextBox6", "Text")
    AccessDataSource1.InsertParameters.Add(country)

    Dim supervisor As New ControlParameter("ReportsTo", "DropDownList1", "SelectedValue")
    AccessDataSource1.InsertParameters.Add(supervisor)

    Try
        AccessDataSource1.Insert()
    Finally
        Button1.Visible = False
        Label9.Visible = True
    End Try

End Sub

注釈

ControlParameterコンストラクターを使用してControlParameter作成されたオブジェクトは、指定したパラメーター名、名前、ControlおよびPropertyNameプロパティを使用して初期化され、パラメーターがバインドされる をControl識別します。 、、、 ConvertEmptyStringToNullなどのTypeDirectionその他のプロパティは、既定値で初期化されます。

こちらもご覧ください

適用対象

ControlParameter(String, DbType, String, String)

指定したパラメーター名、データベース型、コントロール ID、およびプロパティ名を使用して、ControlParameter クラスの新しいインスタンスを初期化します。

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

パラメーター

name
String

パラメーターの名前。

dbType
DbType

パラメーターのデータ型です。

controlID
String

パラメーターのバインド先のコントロールの名前。 既定値は、Empty です。

propertyName
String

パラメーターのバインド先のコントロールのプロパティの名前。 既定値は、Empty です。

適用対象

ControlParameter(String, TypeCode, String, String)

指定されたプロパティ名およびバインド先のコントロールを識別するコントロール名を使用して、ControlParameter クラスの厳密に型指定された名前付きの新しいインスタンスを初期化します。

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

パラメーター

name
String

パラメーターの名前。

type
TypeCode

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

controlID
String

パラメーターのバインド先のコントロールの名前。 既定値は、Empty です。

propertyName
String

パラメーターのバインド先のコントロールのプロパティの名前。 既定値は、Empty です。

次のコードは、コンストラクターを ControlParameter 使用して 2 つの ControlParameter オブジェクトを作成し、それらをコントロールに関連付ける方法を SqlDataSource 示しています。


ControlParameter country =
  new ControlParameter("country",TypeCode.String,"ListBox1","SelectedValue");
sqlSource.SelectParameters.Add(country);

ControlParameter report  =
  new ControlParameter("report",TypeCode.Int16,"ListBox2","SelectedValue");
sqlSource.SelectParameters.Add(report);


Dim country As ControlParameter
country = New ControlParameter("country", TypeCode.String, "ListBox1", "SelectedValue")

Dim report As ControlParameter
report = New ControlParameter("report", TypeCode.Int16, "ListBox2", "SelectedValue")

注釈

ControlParameterコンストラクターを使用してControlParameter作成されたオブジェクトは、指定されたパラメーター名、、名前、 ControlTypeおよびPropertyNameプロパティで初期化されます。 Directionプロパティと ConvertEmptyStringToNull プロパティのみが既定値で初期化されます。

こちらもご覧ください

適用対象