ControlParameter コンストラクタ ()とは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ControlParameter コンストラクタ ()の意味・解説 

ControlParameter コンストラクタ ()

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

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

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim instance As New ControlParameter
public ControlParameter ()
public:
ControlParameter ()
public ControlParameter ()
public function ControlParameter ()
解説解説

ControlParameter コンストラクタ作成されControlParameter オブジェクトは、すべてのプロパティ既定値使用して初期化されます。ControlID プロパティおよび PropertyName プロパティは String.Empty に初期化されています。また、Name プロパティString.Empty初期化され、Type プロパティは TypeCode.Object に初期化されます。さらに、Direction プロパティInput初期化され、DefaultValue プロパティnull 参照 (Visual Basic では Nothing) に初期化されます

使用例使用例

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

<%@ Page Language="VB" AutoEventWireup="false"
 CodeFile="param1avb.aspx.vb" Inherits="param1avb_aspx"
 %>
<html  >
<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="C#" CodeFile="param1acs.aspx.cs" Inherits="param1acs_aspx"
 %>
<html  >
<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="VJ#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
private void Page_Load(Object sender, System.EventArgs
 e)
{
    SqlDataSource sqlSource = new SqlDataSource("Data Source=localhost;"
 
        + "Integrated Security=SSPI;Initial Catalog=Northwind;",
        "SELECT FirstName, LastName FROM Employees WHERE Country = @country;");

    ControlParameter country = new ControlParameter();
    country.set_Name("country");
    country.set_Type(System.TypeCode.String);
    country.set_ControlID("DropDownList1");
    country.set_PropertyName("SelectedValue");

    // If the DefaultValue is not set, the DataGrid does not
    // display anything on the first page load. This is because
    // on the first page load, the DropDownList has no
    // selected item, and the ControlParameter evaluates to
    // String.Empty.
    country.set_DefaultValue("USA");

    sqlSource.get_SelectParameters().Add(country);

    // Add the SqlDataSource to the page controls collection.
    get_Page().get_Controls().Add(sqlSource);

    DataGrid1.set_DataSource(sqlSource);
    DataGrid1.DataBind();
} //Page_Load
</SCRIPT>

<HTML>
    <BODY>
        <FORM runat="server">

        <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" />

        </FORM>
    </BODY>
</HTML>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ControlParameter クラス
ControlParameter メンバ
System.Web.UI.WebControls 名前空間

ControlParameter コンストラクタ (String, String, String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

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

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub New ( _
    name As String, _
    controlID As String, _
    propertyName As String _
)
Dim name As String
Dim controlID As String
Dim propertyName As String

Dim instance As New ControlParameter(name,
 controlID, propertyName)
public ControlParameter (
    string name,
    string controlID,
    string propertyName
)
public:
ControlParameter (
    String^ name, 
    String^ controlID, 
    String^ propertyName
)
public ControlParameter (
    String name, 
    String controlID, 
    String propertyName
)
public function ControlParameter (
    name : String, 
    controlID : String, 
    propertyName : String
)

パラメータ

name

パラメータの名前。

controlID

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

propertyName

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

解説解説
使用例使用例

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

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
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;
    }
}
private void Button1_Click(Object sender, System.EventArgs
 e)
{
    // The user has pressed the Submit button, prepare a parameterized
    // SQL query to insert the values from the controls.
    AccessDataSource1.set_InsertCommand("INSERT INTO Employees" 
        + "(FirstName,LastName,Address,City,PostalCode,Country,ReportsTo) "
 
        + "  VALUES (?,?,?,?,?,?,? ); ");
    AccessDataSource1.get_InsertParameters().Add(new ControlParameter
        ("FirstName", "TextBox1", "Text"));
    AccessDataSource1.get_InsertParameters().Add(new ControlParameter
        ("LastName", "TextBox2", "Text"));
    AccessDataSource1.get_InsertParameters().Add(new ControlParameter
        ("Address", "TextBox3", "Text"));
    AccessDataSource1.get_InsertParameters().Add(new ControlParameter
        ("City", "TextBox4", "Text"));
    AccessDataSource1.get_InsertParameters().Add(new ControlParameter
        ("PostalCode", "TextBox5", "Text"));
    AccessDataSource1.get_InsertParameters().Add(new ControlParameter
        ("Country", "TextBox6", "Text"));
    AccessDataSource1.get_InsertParameters().Add(new ControlParameter
        ("ReportsTo", "DropDownList1", "SelectedValue"));
    try {
        AccessDataSource1.Insert();
    }
    finally {
        Button1.set_Visible(false);
        Label9.set_Visible(true);
    }
} //Button1_Click
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ControlParameter クラス
ControlParameter メンバ
System.Web.UI.WebControls 名前空間
Name
ControlID
PropertyName

ControlParameter コンストラクタ (String, String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

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

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub New ( _
    name As String, _
    controlID As String _
)
Dim name As String
Dim controlID As String

Dim instance As New ControlParameter(name,
 controlID)
public ControlParameter (
    string name,
    string controlID
)
public:
ControlParameter (
    String^ name, 
    String^ controlID
)
public ControlParameter (
    String name, 
    String controlID
)
public function ControlParameter (
    name : String, 
    controlID : String
)

パラメータ

name

パラメータの名前。

controlID

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

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ControlParameter クラス
ControlParameter メンバ
System.Web.UI.WebControls 名前空間
Name
ControlID

ControlParameter コンストラクタ (String, TypeCode, String, String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

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

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub New ( _
    name As String, _
    type As TypeCode, _
    controlID As String, _
    propertyName As String _
)
Dim name As String
Dim type As TypeCode
Dim controlID As String
Dim propertyName As String

Dim instance As New ControlParameter(name,
 type, controlID, propertyName)
public ControlParameter (
    string name,
    TypeCode type,
    string controlID,
    string propertyName
)
public:
ControlParameter (
    String^ name, 
    TypeCode type, 
    String^ controlID, 
    String^ propertyName
)
public ControlParameter (
    String name, 
    TypeCode type, 
    String controlID, 
    String propertyName
)
public function ControlParameter (
    name : String, 
    type : TypeCode, 
    controlID : String, 
    propertyName : String
)

パラメータ

name

パラメータの名前。

type

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

controlID

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

propertyName

パラメータバインド先のコントロールプロパティの名前。既定値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);

ControlParameter country = new ControlParameter("country",
 
    System.TypeCode.String, "ListBox1", "SelectedValue");
sqlSource.get_SelectParameters().Add(country);
ControlParameter report = new ControlParameter("report",
 
    System.TypeCode.Int16, "ListBox2", "SelectedValue");
sqlSource.get_SelectParameters().Add(report);
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ControlParameter クラス
ControlParameter メンバ
System.Web.UI.WebControls 名前空間
Name
Type
ControlID
PropertyName

ControlParameter コンストラクタ (ControlParameter)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

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

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Protected Sub New ( _
    original As ControlParameter _
)
Dim original As ControlParameter

Dim instance As New ControlParameter(original)
protected ControlParameter (
    ControlParameter original
)
protected:
ControlParameter (
    ControlParameter^ original
)
protected ControlParameter (
    ControlParameter original
)
protected function ControlParameter (
    original : ControlParameter
)

パラメータ

original

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

解説解説

ControlParameter コンストラクタは、ControlParameter インスタンスクローン作成するための protected コピー コンストラクタです。ControlParameter オブジェクトの値 (ControlID、PropertyName、NameType プロパティなど) が、すべて新しインスタンス転送されます。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ControlParameter クラス
ControlParameter メンバ
System.Web.UI.WebControls 名前空間
Clone

ControlParameter コンストラクタ




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ControlParameter コンストラクタ ()」の関連用語

ControlParameter コンストラクタ ()のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ControlParameter コンストラクタ ()のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS