SessionParameter コンストラクタ (SessionParameter)
アセンブリ: System.Web (system.web.dll 内)


SessionParameter(SessionParameter) コンストラクタは、SessionParameter インスタンスのクローンを作成するための Protected コピー コンストラクタです。SessionParameter オブジェクトの値 (SessionField、Name、Type プロパティなど) が、すべて新しいインスタンスに転送されます。

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SessionParameter コンストラクタ (String, String)
アセンブリ: System.Web (system.web.dll 内)

Dim name As String Dim sessionField As String Dim instance As New SessionParameter(name, sessionField)

SessionParameter(String,String) コンストラクタを使用して作成された SessionParameter オブジェクトは、指定されたパラメータ名、およびパラメータのバインド先の HttpSessionState 名前/値ペアを識別する文字列を使用して初期化されます。Type および Direction を含むその他のプロパティは既定値を使用して初期化されます。

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SessionParameter コンストラクタ (String, TypeCode, String)
アセンブリ: System.Web (system.web.dll 内)

Dim name As String Dim type As TypeCode Dim sessionField As String Dim instance As New SessionParameter(name, type, sessionField)

SessionParameter コンストラクタを使用して作成された SessionParameter オブジェクトは、指定されたパラメータ名、Type、およびパラメータのバインド先の HttpSessionState 名前/値ペアを識別する文字列を使用して初期化されます。Direction プロパティおよび ConvertEmptyStringToNull プロパティのみ既定値で初期化されます。

SessionParameter コンストラクタを使用して SessionParameter オブジェクトを作成し、それを SqlDataSource コントロールと共に使用して、データを DataGrid コントロールに表示する方法を次のコード例に示します。
<%@ 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> <body MS_POSITIONING="GridLayout"> <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="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> <body MS_POSITIONING="GridLayout"> <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="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 odbcToSql = new SqlDataSource(); // Connect to SQL Server using an ODBC DSN. odbcToSql.set_ProviderName("System.Data.Odbc"); odbcToSql.set_ConnectionString("dsn=MyOdbcDsn;"); // Use an ODBC parameterized query syntax. odbcToSql.set_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",System.TypeCode.String ,"country"); SessionParameter reportsTo = new SessionParameter("report",System.TypeCode.Int32 ,"report"); reportsTo.set_DefaultValue("2"); odbcToSql.get_SelectParameters().Add(country); odbcToSql.get_SelectParameters().Add(reportsTo); // Add the DataSourceControl to the page's Controls collection. get_Page().get_Controls().Add(odbcToSql); DataGrid1.set_DataSource(odbcToSql); DataGrid1.DataBind(); } //Page_Load </SCRIPT> <HTML> <body MS_POSITIONING="GridLayout"> <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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SessionParameter コンストラクタ

名前 | 説明 |
---|---|
SessionParameter () | SessionParameter クラスの名前のない新しいインスタンスを初期化します。 |
SessionParameter (SessionParameter) | original パラメータで指定されたインスタンスの値を使用して、SessionParameter クラスの新しいインスタンスを初期化します。 |
SessionParameter (String, String) | バインド先の HTTP Cookie を識別する文字列を指定して、SessionParameter クラスの名前付きの新しいインスタンスを初期化します。 |
SessionParameter (String, TypeCode, String) | バインド先の HTTP Cookie を識別する文字列を指定して、SessionParameter クラスの厳密に型指定された名前付きの新しいインスタンスを初期化します。 |

SessionParameter コンストラクタ ()
アセンブリ: System.Web (system.web.dll 内)


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

SessionParameter コンストラクタを使用して、SessionParameter クラスの既定のインスタンスを作成する方法を次のコード例に示します。
' 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"

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SessionParameter コンストラクタのページへのリンク