Share via


SessionParameter Konstruktory

Definice

Inicializuje novou instanci SessionParameter třídy.

Přetížení

SessionParameter()

Inicializuje novou nepojmenovanou instanci SessionParameter třídy.

SessionParameter(SessionParameter)

Inicializuje novou instanci SessionParameter třídy s hodnotami instance určené parametrem original .

SessionParameter(String, String)

Inicializuje novou pojmenovanou instanci třídy pomocí zadaného SessionParameter řetězce k identifikaci, ke kterému páru název/hodnota stavu relace se má vytvořit vazba.

SessionParameter(String, DbType, String)

Inicializuje novou instanci třídy pomocí zadaného SessionParameter názvu a typu a vytvoří vazbu parametru na zadaný pár název/hodnota stavu relace. Tento konstruktor je určený pro databázové typy.

SessionParameter(String, TypeCode, String)

Inicializuje novou pojmenovanou instanci třídy a silného typu pomocí zadaného SessionParameter řetězce k identifikaci, ke kterému páru název/hodnota stavu relace se má svázat.

SessionParameter()

Inicializuje novou nepojmenovanou instanci SessionParameter třídy.

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

Příklady

Následující příklad kódu ukazuje, jak vytvořit výchozí instanci SessionParameter třídy pomocí konstruktoru 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"

Poznámky

Objekt SessionParameter vytvořený pomocí konstruktoru SessionParameter je inicializován s výchozími hodnotami pro všechny jeho vlastnosti. Vlastnost SessionField je inicializována na String.Empty. Kromě toho Name je vlastnost inicializována na String.Empty, Type vlastnost je inicializována na TypeCode.Object, Direction vlastnost je inicializována na ParameterDirection.Inputa DefaultValue vlastnost je inicializována na null.

Platí pro

SessionParameter(SessionParameter)

Inicializuje novou instanci SessionParameter třídy s hodnotami instance určené parametrem original .

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)

Parametry

original
SessionParameter

A SessionParameter , ze kterého je inicializována aktuální instance.

Poznámky

Konstruktor SessionParameter(SessionParameter) je konstruktor kopírování, který Protected se používá ke klonování SessionParameter instance. Hodnoty objektu SessionParameter , včetně SessionFieldvlastností , Namea Type , se přenesou do nové instance.

Viz také

Platí pro

SessionParameter(String, String)

Inicializuje novou pojmenovanou instanci třídy pomocí zadaného SessionParameter řetězce k identifikaci, ke kterému páru název/hodnota stavu relace se má vytvořit vazba.

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)

Parametry

name
String

Název parametru

sessionField
String

Název páru HttpSessionState název/hodnota, na který je objekt parametru vázán. Výchozí formát je Empty.

Poznámky

Vlastnosti Type a Direction jsou inicializovány s výchozími hodnotami.

Viz také

Platí pro

SessionParameter(String, DbType, String)

Inicializuje novou instanci třídy pomocí zadaného SessionParameter názvu a typu a vytvoří vazbu parametru na zadaný pár název/hodnota stavu relace. Tento konstruktor je určený pro databázové typy.

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)

Parametry

name
String

Název parametru

dbType
DbType

Typ databáze, který parametr představuje.

sessionField
String

Název páru HttpSessionState název/hodnota, na který je objekt parametru vázán. Výchozí formát je Empty.

Poznámky

Vlastnosti Direction a ConvertEmptyStringToNull jsou inicializovány s výchozími hodnotami.

Platí pro

SessionParameter(String, TypeCode, String)

Inicializuje novou pojmenovanou instanci třídy a silného typu pomocí zadaného SessionParameter řetězce k identifikaci, ke kterému páru název/hodnota stavu relace se má svázat.

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)

Parametry

name
String

Název parametru

type
TypeCode

Typ, který parametr představuje. Výchozí formát je Object.

sessionField
String

Název páru HttpSessionState název/hodnota, na který je objekt parametru vázán. Výchozí formát je Empty.

Příklady

Následující příklad kódu ukazuje, jak pomocí konstruktoru SessionParameterSessionParameter vytvořit objekt a použít ho s ovládacím SqlDataSource prvku k zobrazení dat v ovládacím DataGrid prvku.

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

Poznámky

Vlastnosti Direction a ConvertEmptyStringToNull jsou inicializovány s výchozími hodnotami.

Viz také

Platí pro