Sdílet prostřednictvím


SessionParameter Konstruktory

Definice

Inicializuje novou instanci SessionParameter třídy.

Přetížení

Name Description
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 SessionParameter třídy pomocí zadaného řetězce k identifikaci dvojice název/hodnota stavu relace, ke které 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 typy databází.

SessionParameter(String, TypeCode, String)

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

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. Dále je Name vlastnost inicializována String.Emptyna , Type vlastnost je inicializována DirectionTypeCode.Object, vlastnost je inicializována na ParameterDirection.Input, a vlastnost je inicializována DefaultValue 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 aktuální instance inicializována.

Poznámky

Konstruktor SessionParameter(SessionParameter) je Protected konstruktor kopírování použitý ke klonování SessionParameter instance. Hodnoty objektuSessionParameter, včetně SessionFieldName, a Type vlastnosti, jsou všechny přeneseny do nové instance.

Viz také

Platí pro

SessionParameter(String, String)

Inicializuje novou pojmenovanou instanci SessionParameter třídy pomocí zadaného řetězce k identifikaci dvojice název/hodnota stavu relace, ke které 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 HttpSessionState dvojice name/value, ke které je objekt parametru vázán. Výchozí hodnota je Empty.

Poznámky

Vlastnosti Type jsou Direction 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 typy databází.

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 HttpSessionState dvojice name/value, ke které je objekt parametru vázán. Výchozí hodnota je Empty.

Poznámky

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

Platí pro

SessionParameter(String, TypeCode, String)

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

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í hodnota je Object.

sessionField
String

Název HttpSessionState dvojice name/value, ke které je objekt parametru vázán. Výchozí hodnota je Empty.

Příklady

Následující příklad kódu ukazuje použití SessionParameter konstruktoru k vytvoření objektu SessionParameter a jeho použití 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 jsou ConvertEmptyStringToNull inicializovány s výchozími hodnotami.

Viz také

Platí pro