次の方法で共有


SessionParameter コンストラクター

定義

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

オーバーロード

名前 説明
SessionParameter()

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

SessionParameter(SessionParameter)

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

SessionParameter(String, String)

指定した文字列を使用して、バインド先のセッション状態の名前と値のペアを識別するために、 SessionParameter クラスの新しい名前付きインスタンスを初期化します。

SessionParameter(String, DbType, String)

指定した名前と型を使用して、 SessionParameter クラスの新しいインスタンスを初期化し、パラメーターを指定したセッション状態の名前と値のペアにバインドします。 このコンストラクターはデータベース型用です。

SessionParameter(String, TypeCode, String)

バインド先のセッション状態の名前と値のペアを識別するために、指定した文字列を使用して、 SessionParameter クラスの新しい名前付きの厳密に型指定されたインスタンスを初期化します。

SessionParameter()

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

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

次のコード例では、SessionParameter コンストラクターを使用して、SessionParameter クラスの既定のインスタンスを作成する方法を示します。

// In this example, the session parameter "empid" is set
// after the employee successfully logs in.
SessionParameter empid = new SessionParameter();
empid.Name = "empid";
empid.Type = TypeCode.Int32;
empid.SessionField = "empid";
' In this example, the session parameter "empid" is set
' after the employee successfully logs in.
Dim empid As New SessionParameter()
empid.Name = "empid"
empid.Type = TypeCode.Int32
empid.SessionField = "empid"

注釈

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

適用対象

SessionParameter(SessionParameter)

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

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

パラメーター

original
SessionParameter

現在のインスタンスの初期化元の SessionParameter

注釈

SessionParameter(SessionParameter) コンストラクターは、SessionParameter インスタンスの複製に使用されるProtectedコピー コンストラクターです。 SessionFieldNameTypeプロパティなど、SessionParameter オブジェクトの値はすべて新しいインスタンスに転送されます。

こちらもご覧ください

適用対象

SessionParameter(String, String)

指定した文字列を使用して、バインド先のセッション状態の名前と値のペアを識別するために、 SessionParameter クラスの新しい名前付きインスタンスを初期化します。

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

パラメーター

name
String

パラメーターの名前。

sessionField
String

パラメーター オブジェクトがバインドされている HttpSessionState の名前と値のペアの名前。 既定値は、Empty です。

注釈

TypeプロパティとDirection プロパティは既定値で初期化されます。

こちらもご覧ください

適用対象

SessionParameter(String, DbType, String)

指定した名前と型を使用して、 SessionParameter クラスの新しいインスタンスを初期化し、パラメーターを指定したセッション状態の名前と値のペアにバインドします。 このコンストラクターはデータベース型用です。

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

パラメーター

name
String

パラメーターの名前。

dbType
DbType

パラメーターが表すデータベース型。

sessionField
String

パラメーター オブジェクトがバインドされている HttpSessionState の名前と値のペアの名前。 既定値は、Empty です。

注釈

DirectionプロパティとConvertEmptyStringToNull プロパティは既定値で初期化されます。

適用対象

SessionParameter(String, TypeCode, String)

バインド先のセッション状態の名前と値のペアを識別するために、指定した文字列を使用して、 SessionParameter クラスの新しい名前付きの厳密に型指定されたインスタンスを初期化します。

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

パラメーター

name
String

パラメーターの名前。

type
TypeCode

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

sessionField
String

パラメーター オブジェクトがバインドされている HttpSessionState の名前と値のペアの名前。 既定値は、Empty です。

次のコード例では、 SessionParameter コンストラクターを使用して SessionParameter オブジェクトを作成し、それを SqlDataSource コントロールと共に使用して、 DataGrid コントロールにデータを表示する方法を示します。

<%@ 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">
private void Page_Load(object sender, System.EventArgs e)
{
    SqlDataSource OdbcToSql = new SqlDataSource();

    // Connect to SQL Server using an ODBC DSN.
    OdbcToSql.ProviderName= "System.Data.Odbc";
    OdbcToSql.ConnectionString = "dsn=MyOdbcDsn;";

    // Use an ODBC parameterized query syntax.
    OdbcToSql.SelectCommand = "SELECT EmployeeID FROM Employees " +
                              " WHERE Country = ? AND ReportsTo = ?";

    // The country parameter has no default value, so be sure to set
    // a Session variable named "country" to "UK" or "USA".
    SessionParameter country =
        new SessionParameter("country",TypeCode.String,"country");

    SessionParameter reportsTo =
        new SessionParameter("report",TypeCode.Int32,"report");
    reportsTo.DefaultValue = "2";

    OdbcToSql.SelectParameters.Add(country);
    OdbcToSql.SelectParameters.Add(reportsTo);

    // Add the DataSourceControl to the page's Controls collection.
    Page.Controls.Add(OdbcToSql);

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

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="Form1" method="post" runat="server">
            <asp:DataGrid
                id="DataGrid1"
                style="Z-INDEX: 101; LEFT: 56px; POSITION: absolute; TOP: 56px"
                runat="server" />
        </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)

    Dim OdbcToSql As New SqlDataSource()

    ' Connect to SQL Server using an ODBC DSN.
    OdbcToSql.ProviderName= "System.Data.Odbc"
    OdbcToSql.ConnectionString = "dsn=MyOdbcDsn;"

    ' Use an ODBC parameterized query syntax.
    OdbcToSql.SelectCommand = "SELECT EmployeeID FROM Employees " & _
                              " WHERE Country = ? AND ReportsTo = ?"

    ' The country parameter has no default value, so be sure to set
    ' a Session variable named "country" to "UK" or "USA".
    Dim country As SessionParameter
    country = New SessionParameter("country",TypeCode.String,"country")

    Dim reportsTo As SessionParameter
    reportsTo = New SessionParameter("report",TypeCode.Int32,"report")
    reportsTo.DefaultValue = "2"

    OdbcToSql.SelectParameters.Add(country)
    OdbcToSql.SelectParameters.Add(reportsTo)

    ' Add the DataSourceControl to the page's Controls collection.
    Page.Controls.Add(OdbcToSql)

    DataGrid1.DataSource = OdbcToSql
    DataGrid1.DataBind()

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" method="post" runat="server">
      <asp:DataGrid
          id="DataGrid1"
          style="Z-INDEX: 101; LEFT: 56px; POSITION: absolute; TOP: 56px"
          runat="server" />
    </form>
  </body>
</html>

注釈

DirectionプロパティとConvertEmptyStringToNull プロパティは既定値で初期化されます。

こちらもご覧ください

適用対象