parameterとは? わかりやすく解説

Parameter クラス

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

アプリケーション変数ユーザー IDユーザー選択、および他のデータバインドするためにデータ ソース コントロール使用する機構提供しますASP.NETすべてのパラメータ型の基本クラスとして機能します

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

Public Class Parameter
    Implements ICloneable, IStateManager
public class Parameter : ICloneable, IStateManager
public ref class Parameter : ICloneable, IStateManager
public class Parameter implements ICloneable,
 IStateManager
public class Parameter implements ICloneable,
 IStateManager
解説解説

Parameter クラスは、ASP.NET データ ソース コントロールデータ選択フィルタ処理変更使用するパラメータ化された SQL クエリフィルタ式、またはビジネス オブジェクト メソッド呼び出しパラメータ表しますParameter オブジェクトは、ParameterCollection オブジェクト格納されます。Parameter オブジェクト実行時評価され、それらのオブジェクトが表す変数の値をデータ ソース コントロール使用するメソッドバインドしてデータやり取ります。

ControlParameter、CookieParameter、SessionParameter、ProfileParameter、QueryStringParameter など、ASP.NET提供されるパラメータ クラスは、Web ベースデータ アプリケーションビルドするデータ ソース コントロールおよびデータ バインド コントロール使用します。これらのクラスデータ ソース コントロール使用されWeb アプリケーション内の特定の種類の値を、SQL クエリ文字列ビジネス オブジェクト メソッドパラメータなどに含まれるプレースホルダにバインドます。たとえば、ControlParameter クラスWeb サーバー コントロールパブリック プロパティバインドするために使用されSessionParameter クラスユーザー セッションの値をバインドするために使用されます。また、QueryStringParameter クラスCookieParameter クラスは、HttpRequest クラスの値にバインドするために使用されます。独自のカスタム パラメータ型を実装する場合は、基本 Parameter クラス拡張します。

Parameter オブジェクトは非常に簡単なオブジェクトです。このオブジェクトには、Name プロパティType プロパティあります。このオブジェクトは、宣言によって表すことができ、複数HTTP 要求にわたり状態を追跡できますパラメータが値にバインドされたときのために、すべてのパラメータDefaultValue プロパティサポートしていますが、この値は実行時null 参照 (Visual Basic では Nothing) と評価されます。

データ ソース コントロールParameter オブジェクトコレクション使用する場合コレクション内でのオブジェクト順序が重要となりますパラメータ使用されるしくみの詳細については、「SqlDataSource コントロールにおけるパラメータ使用」および「ObjectDataSource コントロールにおけるパラメータ使用」を参照してください

使用例使用例

宣言シナリオで、Parameter オブジェクト使用してListBox コントロール表示されデータDropDownList コントロール選択された値にバインドする方法次のコード例示しますControlParameter オブジェクトは、フォームの SqlDataSource コントロールの SelectParameters コレクション追加され、SelectCommand プロパティの "@Title" プレースホルダ テキスト対応します

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <body>
    <form runat="server">

      <p><asp:dropdownlist
          id="DropDownList1"
          runat="server"
          autopostback="True">
          <asp:listitem selected>Sales Representative</asp:listitem>
          <asp:listitem>Sales Manager</asp:listitem>
          <asp:listitem>Vice President, Sales</asp:listitem>
      </asp:dropdownlist></p>

      <asp:sqldatasource
          id="SqlDataSource1"
          runat="server"
          connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
          selectcommand="SELECT LastName FROM Employees WHERE
 Title = @Title">
          <selectparameters>
              <asp:controlparameter name="Title"
 controlid="DropDownList1" propertyname="SelectedValue"/>
          </selectparameters>
      </asp:sqldatasource>

      <p><asp:listbox
          id="ListBox1"
          runat="server"
          datasourceid="SqlDataSource1"
          datatextfield="LastName">
      </asp:listbox></p>

    </form>
  </body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <body>
    <form runat="server">

      <p><asp:dropdownlist
          id="DropDownList1"
          runat="server"
          autopostback="True">
          <asp:listitem selected>Sales Representative</asp:listitem>
          <asp:listitem>Sales Manager</asp:listitem>
          <asp:listitem>Vice President, Sales</asp:listitem>
      </asp:dropdownlist></p>

      <asp:sqldatasource
          id="SqlDataSource1"
          runat="server"
          connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
          selectcommand="SELECT LastName FROM Employees WHERE Title = @Title">
          <selectparameters>
              <asp:controlparameter name="Title" controlid="DropDownList1"
 propertyname="SelectedValue"/>
          </selectparameters>
      </asp:sqldatasource>

      <p><asp:listbox
          id="ListBox1"
          runat="server"
          datasourceid="SqlDataSource1"
          datatextfield="LastName">
      </asp:listbox></p>

    </form>
  </body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
  <BODY>
    <FORM runat="server">

      <p><asp:DropDownList
          id="DropDownList1"
          runat="server"
          AutoPostBack="True">
          <asp:ListItem Selected>Sales Representative</asp:ListItem>
          <asp:ListItem>Sales Manager</asp:ListItem>
          <asp:ListItem>Vice President, Sales</asp:ListItem>
      </asp:DropDownList></p>

      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          ConnectionString="Data Source=localhost;Integrated Security=SSPI;Initial
 Catalog=Northwind;"
          SelectCommand="SELECT LastName FROM Employees WHERE Title = @Title">
          <SelectParameters>
              <asp:ControlParameter Name="Title" ControlId="DropDownList1"
 PropertyName="SelectedValue"/>
          </SelectParameters>
      </asp:SqlDataSource>

      <p><asp:ListBox
          id="ListBox1"
          runat="server"
          DataSourceID="SqlDataSource1"
          DataTextField="LastName">
      </asp:ListBox></p>

    </FORM>
  </BODY>
</HTML>

プログラム シナリオで、Parameter オブジェクト使用して、DataGrid コントロール表示されデータDropDownList コントロール選択された値にバインドするコード例次に示しますページ最初に読み込まれときにはDropDownList コントロールの値は選択されていないため、Parameter オブジェクトDefaultValue プロパティ使用されます。

<%@ 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>

次の分離コード モジュールは、前の Web フォーム ページ使用されます。

Partial Class param1avb_aspx
   Inherits System.Web.UI.Page
    Private Sub Page_Load(ByVal
 sender As Object, ByVal
 e As System.EventArgs)

        Dim sqlSource As SqlDataSource

        sqlSource = New SqlDataSource(ConfigurationManager.ConnectionStrings("MyNorthwind").ConnectionString,
 "SELECT FirstName, LastName FROM Employees WHERE Country = @country;")
        Dim country As New
 ControlParameter()
        country.Name = "country"
        country.Type = TypeCode.String
        country.ControlID = "DropDownList1"
        country.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.DefaultValue = "USA"
        sqlSource.SelectParameters.Add(country)

        ' Add the SqlDataSource to the page controls collection.
        Page.Controls.Add(sqlSource)


        DataGrid1.DataSource = sqlSource
        DataGrid1.DataBind()

    End Sub 'Page_Load
End Class
public partial class param1acs_aspx : System.Web.UI.Page
 
{
    private void Page_Load(object sender, System.EventArgs
 e)
    {
        SqlDataSource sqlSource = new SqlDataSource(
          ConfigurationManager.ConnectionStrings["MyNorthwind"].ConnectionString
,
          "SELECT FirstName, LastName FROM Employees WHERE Country = @country;");

        ControlParameter country = new ControlParameter();
        country.Name = "country";
        country.Type = TypeCode.String;
        country.ControlID = "DropDownList1";
        country.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.DefaultValue = "USA";

        sqlSource.SelectParameters.Add(country);

        // Add the SqlDataSource to the page controls collection.
        Page.Controls.Add(sqlSource);

        DataGrid1.DataSource = sqlSource;
        DataGrid1.DataBind();
    }
}

Parameter クラス拡張してデータ バインディング シナリオデータ ソース コントロールと他のコントロール使用できる新しパラメータ型を作成する方法次のコード例示しますデータ ソース コントロールは、StaticParameter パラメータ使用してWeb フォーム ページ上で宣言されオブジェクトの値 (通常は文字列) にバインドできます

Imports System
Imports System.ComponentModel
Imports System.Security.Permissions
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace Samples.AspNet

<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)>
 _
Public Class StaticParameter
   Inherits Parameter


   Public Sub New()
   End Sub

  ' The StaticParameter(string, object) constructor
  ' initializes the DataValue property and calls the
  ' Parameter(string) constructor to initialize the Name property.
   Public Sub New(name As
 String, value As Object)
      MyBase.New(name)
      DataValue = value
   End Sub

   ' The StaticParameter(string, TypeCode, object) constructor
   ' initializes the DataValue property and calls the
   ' Parameter(string, TypeCode) constructor to initialize the Name
 and
   ' Type properties.
   Public Sub New(name As
 String, type As TypeCode, value As
 Object)
      MyBase.New(name, type)
      DataValue = value
   End Sub
   ' The StaticParameter copy constructor is provided to ensure that
   ' the state contained in the DataValue property is copied to new
   ' instances of the class.
   Protected Sub New(original
 As StaticParameter)
      MyBase.New(original)
      DataValue = original.DataValue
   End Sub

   ' The Clone method is overridden to call the
   ' StaticParameter copy constructor, so that the data in
   ' the DataValue property is correctly transferred to the
   ' new instance of the StaticParameter.
   Protected Overrides Function
 Clone() As Parameter
      Return New StaticParameter(Me)
   End Function

   ' The DataValue can be any arbitrary object and is stored in ViewState.
   Public Property DataValue() As
 Object
      Get
         Return ViewState("Value")
      End Get
      Set
         ViewState("Value") = value
      End Set
   End Property
   ' The Value property is a type safe convenience property
   ' used when the StaticParameter represents string data.
   ' It gets the string value of the DataValue property, and
   ' sets the DataValue property directly.
   Public Property Value() As
 String
      Get
         Dim o As Object
 = DataValue
         If o Is Nothing
 OrElse Not TypeOf o Is
 String Then
            Return String.Empty
         End If
         Return CStr(o)
      End Get
      Set
         DataValue = value
         OnParameterChanged()
      End Set
   End Property
   ' The Evaluate method is overridden to return the
   ' DataValue property instead of the DefaultValue.
   Protected Overrides Function
 Evaluate(context As HttpContext, control As
 Control) As Object
      If context Is Nothing
 Then
          Return Nothing
      Else
          Return DataValue
      End If
   End Function
End Class ' StaticParameter

End Namespace ' Samples.AspNet
namespace Samples.AspNet {

  using System;
  using System.ComponentModel;
  using System.Security.Permissions;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;

  [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
  public class StaticParameter : Parameter
 {

    public StaticParameter() {
    }
    // The StaticParameter(string, object) constructor
    // initializes the DataValue property and calls the
    // Parameter(string) constructor to initialize the Name property.
    public StaticParameter(string name, object
 value) : base(name) {
      DataValue = value;
    }
    // The StaticParameter(string, TypeCode, object) constructor
    // initializes the DataValue property and calls the
    // Parameter(string, TypeCode) constructor to initialize the Name
 and
    // Type properties.
    public StaticParameter(string name, TypeCode
 type, object value) : base(name, type) {
      DataValue = value;
    }
    // The StaticParameter copy constructor is provided to ensure that
    // the state contained in the DataValue property is copied to new
    // instances of the class.
    protected StaticParameter(StaticParameter original) : base(original)
 {
      DataValue = original.DataValue;
    }

    // The Clone method is overridden to call the
    // StaticParameter copy constructor, so that the data in
    // the DataValue property is correctly transferred to the
    // new instance of the StaticParameter.
    protected override Parameter Clone() {
      return new StaticParameter(this);
    }
    // The DataValue can be any arbitrary object and is stored in ViewState.
    public object DataValue {
      get {
        return ViewState["Value"];
      }
      set {
        ViewState["Value"] = value;
      }
    }
    // The Value property is a type safe convenience property
    // used when the StaticParameter represents string data.
    // It gets the string value of the DataValue property, and
    // sets the DataValue property directly.
    public string Value {
      get {
        object o = DataValue;
        if (o == null || !(o is string))
          return String.Empty;
        return (string)o;
      }
      set {
        DataValue = value;
        OnParameterChanged();
      }
    }

    // The Evaluate method is overridden to return the
    // DataValue property instead of the DefaultValue.
    protected override object Evaluate(HttpContext context, Control
 control) {

      if (context.Request == null)
          return null;

      return DataValue;
    }
  }
}
package Samples.AspNet ;
import System.* ;
import System.ComponentModel.* ;
import System.Web.UI.* ;
import System.Web.UI.WebControls.* ;

public class StaticParameter extends Parameter
{
    public StaticParameter()
    {
    } //StaticParameter


    // The StaticParameter(string, object) constructor
    // initializes the DataValue property and calls the 
    // Parameter(string) constructor to initialize the Name property.
    public StaticParameter(String name, Object value)
    {
        super(name);
        set_DataValue(value);
    } //StaticParameter

    
    // The StaticParameter(string, TypeCode, object) constructor
    // initializes the DataValue property and calls the 
    // Parameter(string, TypeCode) constructor to initialize the Name
 and 
    // Type properties.
    public StaticParameter(String name, TypeCode type, Object
 value)
    {
        super(name, type);
        set_DataValue(value);
    } //StaticParameter

    
    // The StaticParameter copy constructor is provided to ensure that
 
    // the state contained in the DataValue property is copied to new
    // instances of the class. 
    protected StaticParameter(StaticParameter original)
    {
        super(original);
        set_DataValue(original.get_DataValue());
    } //StaticParameter


    // The Clone method is overridden to call the 
    // StaticParameter copy constructor, so that the data in 
    // the DataValue property is correctly transferred to the 
    // new instance of the StaticParameter.
    protected Parameter Clone()
    {
        return new StaticParameter(this);
    } //Clone

    
    // The DataValue can be any arbitrary object and is stored in ViewState.
    /** @property 
     */
    public Object get_DataValue()
    {
        return get_ViewState().get_Item("Value");
    } //get_DataValue


    /** @property 
     */
    public void set_DataValue(Object value)
    {
        get_ViewState().set_Item("Value", value);
    } //set_DataValue

    
    // The Value property is a type safe convenience property 
    // used when the StaticParameter represents string data.
    // It gets the string value of the DataValue property, and
    // sets the DataValue property directly.
    /** @property 
     */
    public String get_Value()
    {
        Object o = get_DataValue();

        if (o == null || !(o instanceof String))
 {
            return String.Empty;
        }

        return (String)(o);
    } //get_Value


    /** @property 
     */
    public void set_Value(String value)
    {
        set_DataValue(value);
        OnParameterChanged();
    } //set_Value

    
    // The Evaluate method is overridden to return the 
    // DataValue property instead of the DefaultValue.
    protected Object Evaluate(Control control)
    {
        return get_DataValue();
    } //Evaluate
} //StaticParameter
継承階層継承階層
System.Object
  System.Web.UI.WebControls.Parameter
     派生クラス
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Parameter メンバ
System.Web.UI.WebControls 名前空間
ControlParameter クラス
CookieParameter クラス
FormParameter クラス
QueryStringParameter
SessionParameter
ParameterCollection
DataSourceControl
その他の技術情報
データ ソース コントロールパラメータ使用

Parameter コンストラクタ ()

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

Parameter クラス新し既定インスタンス初期化します。

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

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

Parameter コンストラクタ (Parameter)

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

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

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

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

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

パラメータ

original

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

解説解説

Parameter(Parameter) コンストラクタは、Parameter インスタンスクローン作成するための protected コピー コンストラクタです。NameTypeDefaultValueDirection、ConvertEmptyStringToNull の各プロパティの値は、すべて新しインスタンス転送されます。

使用例使用例

Parameter クラス拡張したクラスから Parameter(Parameter) コンストラクタ呼び出してクラスオブジェクト適切なクローン動作実装する方法次のコード例示します。このコード例Parameter クラス概要取り上げているコード例一部分です。

' The StaticParameter copy constructor is provided to ensure that
' the state contained in the DataValue property is copied to new
' instances of the class.
Protected Sub New(original
 As StaticParameter)
   MyBase.New(original)
   DataValue = original.DataValue
End Sub

' The Clone method is overridden to call the
' StaticParameter copy constructor, so that the data in
' the DataValue property is correctly transferred to the
' new instance of the StaticParameter.
Protected Overrides Function
 Clone() As Parameter
   Return New StaticParameter(Me)
End Function
// The StaticParameter copy constructor is provided to ensure that
// the state contained in the DataValue property is copied to new
// instances of the class.
protected StaticParameter(StaticParameter original) : base(original)
 {
  DataValue = original.DataValue;
}

// The Clone method is overridden to call the
// StaticParameter copy constructor, so that the data in
// the DataValue property is correctly transferred to the
// new instance of the StaticParameter.
protected override Parameter Clone() {
  return new StaticParameter(this);
}
// The StaticParameter copy constructor is provided to ensure that 
// the state contained in the DataValue property is copied to new
// instances of the class. 
protected StaticParameter(StaticParameter original)
{
    super(original);
    set_DataValue(original.get_DataValue());
} //StaticParameter


// The Clone method is overridden to call the 
// StaticParameter copy constructor, so that the data in 
// the DataValue property is correctly transferred to the 
// new instance of the StaticParameter.
protected Parameter Clone()
{
    return new StaticParameter(this);
} //Clone
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Parameter クラス
Parameter メンバ
System.Web.UI.WebControls 名前空間
Clone

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

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

DefaultValue プロパティ指定した名前、型、文字列使用してParameter クラス新しインスタンス初期化します。

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

Public Sub New ( _
    name As String, _
    type As TypeCode, _
    defaultValue As String _
)
public Parameter (
    string name,
    TypeCode type,
    string defaultValue
)
public:
Parameter (
    String^ name, 
    TypeCode type, 
    String^ defaultValue
)
public Parameter (
    String name, 
    TypeCode type, 
    String defaultValue
)
public function Parameter (
    name : String, 
    type : TypeCode, 
    defaultValue : String
)

パラメータ

name

パラメータの名前。

type

プロパティの型を表す TypeCode。

defaultValue

Evaluate の呼び出し時に、Parameter がまだ初期化されていない値にバインドされている場合に、パラメータ既定値として使用する文字列

解説解説
使用例使用例

Parameter(String,TypeCode,String) コンストラクタ使用してUpdate メソッド呼び出す前に、AccessDataSource コントロールの UpdateParameters コレクション更新パラメータ オブジェクト追加する方法次のコード例示します

<SCRIPT runat="server">
Private Sub UpdateRecords(source As
 Object, e As EventArgs)

  ' This method is an example of batch updating using a
  ' data source control. The method iterates through the rows
  ' of the GridView, extracts each CheckBox from the row and, if
  ' the CheckBox is checked, updates data by calling the Update
  ' method of the data source control, adding required parameters
  ' to the UpdateParameters collection.

  Dim cb As CheckBox
  Dim row As GridViewRow

  For Each row In GridView1.Rows

    cb = CType(row.Cells(0).Controls(1), CheckBox)
    If cb.Checked Then

      Dim oid As String
      oid = CType(row.Cells(1).Text, String)

      Dim param1 As New
 Parameter("date", TypeCode.DateTime, DateTime.Now.ToString())
      MyAccessDataSource.UpdateParameters.Add(param1)

      Dim param2 As New
 Parameter("orderid", TypeCode.String, oid)
      MyAccessDataSource.UpdateParameters.Add(param2)

      MyAccessDataSource.Update()
      MyAccessDataSource.UpdateParameters.Clear()
    End If
  Next
End Sub ' UpdateRecords
</SCRIPT>
<SCRIPT runat="server">
private void UpdateRecords(Object source, EventArgs
 e)
{
  // This method is an example of batch updating using a
  // data source control. The method iterates through the rows
  // of the GridView, extracts each CheckBox from the row and, if
  // the CheckBox is checked, updates data by calling the Update
  // method of the data source control, adding required parameters
  // to the UpdateParameters collection.
  CheckBox cb;
  foreach(GridViewRow row in this.GridView1.Rows)
 {
    cb = (CheckBox) row.Cells[0].Controls[1];
    if(cb.Checked) {
      string oid = (string) row.Cells[1].Text;
      MyAccessDataSource.UpdateParameters.Add(new Parameter("date"
,TypeCode.DateTime,DateTime.Now.ToString()));
      MyAccessDataSource.UpdateParameters.Add(new Parameter("orderid"
,TypeCode.String,oid));
      MyAccessDataSource.Update();
      MyAccessDataSource.UpdateParameters.Clear();
    }
  }
}
</SCRIPT>
<SCRIPT runat="server">
    private void UpdateRecords(Object source,
 System.EventArgs e)
    {
        // This method is an example of batch updating using a
        // data source control. The method iterates through the rows
        // of the GridView, extracts each CheckBox from the row and,
 if
        // the CheckBox is checked, updates data by calling the Update
        // method of the data source control, adding required parameters
        // to the UpdateParameters collection.
        CheckBox cb;
        for (int iCtr = 0; 
                iCtr < this.GridView1.get_Rows().get_Count();
 iCtr++) {
            GridViewRow row = this.GridView1.get_Rows().get_Item(iCtr);
            cb = (CheckBox)row.get_Cells().get_Item(0).get_Controls().get_Item(1);
            if (cb.get_Checked()) {
                String oid = (String)(row.get_Cells().get_Item(1).get_Text());
                MyAccessDataSource.get_UpdateParameters().Add(new
 Parameter(
                    "date", System.TypeCode.DateTime, System.DateTime.get_Now().ToString()));
                MyAccessDataSource.get_UpdateParameters().Add(new
 Parameter(
                    "orderid", System.TypeCode.String, oid));
                MyAccessDataSource.Update();
                MyAccessDataSource.get_UpdateParameters().Clear();
            }
        }
    } //UpdateRecords
</SCRIPT>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Parameter クラス
Parameter メンバ
System.Web.UI.WebControls 名前空間
Name
Type
DefaultValue

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

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

名前と型を指定して、Parameter クラス新しインスタンス初期化します。

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

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

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

パラメータ

name

パラメータの名前。

type

パラメータの型を表す TypeCode。

解説解説
使用例使用例

Parameter クラス拡張したクラスから Parameter(String,TypeCode) コンストラクタ呼び出してインスタンスName プロパティType プロパティ初期化する方法次のコード例示します。このコード例は、Parameter クラス概要取り上げているコード例一部分です。

' The StaticParameter(string, TypeCode, object) constructor
' initializes the DataValue property and calls the
' Parameter(string, TypeCode) constructor to initialize the Name and
' Type properties.
Public Sub New(name As
 String, type As TypeCode, value As
 Object)
   MyBase.New(name, type)
   DataValue = value
End Sub
// The StaticParameter(string, TypeCode, object) constructor
// initializes the DataValue property and calls the
// Parameter(string, TypeCode) constructor to initialize the Name and
// Type properties.
public StaticParameter(string name, TypeCode
 type, object value) : base(name, type) {
  DataValue = value;
}
// The StaticParameter(string, TypeCode, object) constructor
// initializes the DataValue property and calls the 
// Parameter(string, TypeCode) constructor to initialize the Name and
 
// Type properties.
public StaticParameter(String name, TypeCode type, Object value)
{
    super(name, type);
    set_DataValue(value);
} //StaticParameter
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Parameter クラス
Parameter メンバ
System.Web.UI.WebControls 名前空間
Name
Type

Parameter コンストラクタ

Parameter クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

参照参照

関連項目

Parameter クラス
Parameter メンバ
System.Web.UI.WebControls 名前空間

Parameter コンストラクタ (String)

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

名前を指定して、Parameter クラス新しインスタンス初期化します。

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

解説解説
使用例使用例

Parameter クラス拡張したクラスから Parameter(String) コンストラクタ呼び出してインスタンスName プロパティ初期化する方法次のコード例示します。このコード例Parameter クラス概要取り上げているコード例一部分です。

' The StaticParameter(string, object) constructor
' initializes the DataValue property and calls the
' Parameter(string) constructor to initialize the Name property.
 Public Sub New(name As
 String, value As Object)
    MyBase.New(name)
    DataValue = value
 End Sub
// The StaticParameter(string, object) constructor
// initializes the DataValue property and calls the
// Parameter(string) constructor to initialize the Name property.
public StaticParameter(string name, object
 value) : base(name) {
  DataValue = value;
}
// The StaticParameter(string, object) constructor
// initializes the DataValue property and calls the 
// Parameter(string) constructor to initialize the Name property.
public StaticParameter(String name, Object value)
{
    super(name);
    set_DataValue(value);
} //StaticParameter
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Parameter クラス
Parameter メンバ
System.Web.UI.WebControls 名前空間
Name

Parameter プロパティ


パブリック プロパティパブリック プロパティ

プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ IsTrackingViewState Parameter オブジェクトビューステートへの変更保存しているかどうかを示す値を取得します
プロテクト プロパティ ViewState 同一ページ対す複数要求わたってParameter オブジェクトビューステート保存し復元できるようにする状態情報のディクショナリを取得します
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Web.UI.IStateManager.IsTrackingViewState Parameter オブジェクトビューステートへの変更保存しているかどうかを示す値を取得します
参照参照

関連項目

Parameter クラス
System.Web.UI.WebControls 名前空間
ControlParameter クラス
CookieParameter クラス
FormParameter クラス
QueryStringParameter
SessionParameter
ParameterCollection
DataSourceControl

その他の技術情報

データ ソース コントロールパラメータ使用

Parameter メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.ICloneable.Clone 現在の Parameter インスタンス複製返します
インターフェイスの明示的な実装 System.Web.UI.IStateManager.LoadViewState データ ソース ビューの、以前保存したビューステート復元します。
インターフェイスの明示的な実装 System.Web.UI.IStateManager.SaveViewState ページサーバーポストバックされた時間以降発生したParameter オブジェクトビューステートへの変更保存します
インターフェイスの明示的な実装 System.Web.UI.IStateManager.TrackViewState Parameter オブジェクトがそのビューステート変更追跡するようにします。それにより、変更コントロールViewState オブジェクト格納して、同じページ対す複数要求わたって永続化できます
参照参照

関連項目

Parameter クラス
System.Web.UI.WebControls 名前空間
ControlParameter クラス
CookieParameter クラス
FormParameter クラス
QueryStringParameter
SessionParameter
ParameterCollection
DataSourceControl

その他の技術情報

データ ソース コントロールパラメータ使用

Parameter メンバ

アプリケーション変数ユーザー IDユーザー選択、および他のデータバインドするためにデータ ソース コントロール使用する機構提供しますASP.NETすべてのパラメータ型の基本クラスとして機能します

Parameter データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
プロテクト コンストラクタプロテクト コンストラクタ
パブリック プロパティパブリック プロパティ
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ IsTrackingViewState Parameter オブジェクトビューステートへの変更保存しているかどうかを示す値を取得します
プロテクト プロパティ ViewState 同一ページ対す複数要求わたってParameter オブジェクトビューステート保存し復元できるようにする状態情報のディクショナリを取得します
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.ICloneable.Clone 現在の Parameter インスタンス複製返します
インターフェイスの明示的な実装 System.Web.UI.IStateManager.LoadViewState データ ソース ビューの、以前保存したビューステート復元します。
インターフェイスの明示的な実装 System.Web.UI.IStateManager.SaveViewState ページサーバーポストバックされた時間以降発生したParameter オブジェクトビューステートへの変更保存します
インターフェイスの明示的な実装 System.Web.UI.IStateManager.TrackViewState Parameter オブジェクトがそのビューステート変更追跡するようにします。それにより、変更コントロールViewState オブジェクト格納して、同じページ対す複数要求わたって永続化できます
インターフェイスの明示的な実装 System.Web.UI.IStateManager.IsTrackingViewState Parameter オブジェクトビューステートへの変更保存しているかどうかを示す値を取得します
参照参照

関連項目

Parameter クラス
System.Web.UI.WebControls 名前空間
ControlParameter クラス
CookieParameter クラス
FormParameter クラス
QueryStringParameter
SessionParameter
ParameterCollection
DataSourceControl

その他の技術情報

データ ソース コントロールパラメータ使用


このページでは「.NET Framework クラス ライブラリ リファレンス」からparameterを検索した結果を表示しています。
Weblioに収録されているすべての辞書からparameterを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からparameterを検索

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

辞書ショートカット

すべての辞書の索引

「parameter」の関連用語

parameterのお隣キーワード
検索ランキング

   

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



parameterのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS