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初期化されDefaultValueDirection プロパティは にParameterDirection.Inputnull初期化されます。

適用対象

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) 、インスタンスの Protected 複製に使用されるコピー コンストラクターです SessionParameter 。 、、および Type プロパティをSessionParameter含むオブジェクトのNameSessionField値はすべて、新しいインスタンスに転送されます。

こちらもご覧ください

適用対象

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 プロパティは既定値で初期化されます。

こちらもご覧ください

適用対象