แก้ไข

แชร์ผ่าน


Parameter Constructors

Definition

Initializes a new instance of the Parameter class.

Overloads

Parameter()

Initializes a new default instance of the Parameter class.

Parameter(String)

Initializes a new instance of the Parameter class, using the specified name.

Parameter(Parameter)

Initializes a new instance of the Parameter class with the values of the original, specified instance.

Parameter(String, DbType)

Initializes a new instance of the Parameter class, using the specified name and database type.

Parameter(String, TypeCode)

Initializes a new instance of the Parameter class, using the specified name and type.

Parameter(String, DbType, String)

Initializes a new instance of the Parameter class, using the specified name, the specified database type, and the specified value for its DefaultValue property.

Parameter(String, TypeCode, String)

Initializes a new instance of the Parameter class, using the specified name, the specified type, and the specified string for its DefaultValue property.

Parameter()

Initializes a new default instance of the Parameter class.

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

Remarks

A Parameter object created with the Parameter() constructor is initialized with default values for all its properties. The Name property is initialized to String.Empty, the Type property is initialized to TypeCode.Object, the Direction property is initialized to Input, and the DefaultValue property is initialized to null.

Applies to

Parameter(String)

Initializes a new instance of the Parameter class, using the specified name.

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

Parameters

name
String

The name of the parameter.

Examples

The following code example demonstrates how to call the Parameter(String) constructor from a class that extends the Parameter class to initialize the Name property of the instance. This code example is part of a larger example provided for the Parameter class overview.

// The StaticParameter(string, object) constructor
// initializes the DataValue property and calls the
// Parameter(string) constructor to initialize the Name property.
public StaticParameter(string name, object value) : base(name) {
  DataValue = value;
}
' The StaticParameter(string, object) constructor
' initializes the DataValue property and calls the
' Parameter(string) constructor to initialize the Name property.
 Public Sub New(name As String, value As Object)
    MyBase.New(name)
    DataValue = value
 End Sub

Remarks

A Parameter object created with the Parameter(String) constructor is initialized with the specified name and default values for its other properties. The Type property is initialized to TypeCode.Object, the Direction property is initialized to Input, and the DefaultValue property is initialized to null.

See also

Applies to

Parameter(Parameter)

Initializes a new instance of the Parameter class with the values of the original, specified instance.

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

Parameters

original
Parameter

A Parameter instance from which the current instance is initialized.

Examples

The following code example demonstrates how to call the Parameter(Parameter) constructor from a class that extends the Parameter class to implement correct object cloning behavior for the class. This code example is part of a larger example provided for the Parameter class overview.

// The StaticParameter copy constructor is provided to ensure that
// the state contained in the DataValue property is copied to new
// instances of the class.
protected StaticParameter(StaticParameter original) : base(original) {
  DataValue = original.DataValue;
}

// The Clone method is overridden to call the
// StaticParameter copy constructor, so that the data in
// the DataValue property is correctly transferred to the
// new instance of the StaticParameter.
protected override Parameter Clone() {
  return new StaticParameter(this);
}
' The StaticParameter copy constructor is provided to ensure that
' the state contained in the DataValue property is copied to new
' instances of the class.
Protected Sub New(original As StaticParameter)
   MyBase.New(original)
   DataValue = original.DataValue
End Sub

' The Clone method is overridden to call the
' StaticParameter copy constructor, so that the data in
' the DataValue property is correctly transferred to the
' new instance of the StaticParameter.
Protected Overrides Function Clone() As Parameter
   Return New StaticParameter(Me)
End Function

Remarks

The Parameter(Parameter) constructor is a protected copy constructor used to clone a Parameter instance. The values of the Name, Type, DefaultValue, Direction, and ConvertEmptyStringToNull properties are all transferred to the new instance.

See also

Applies to

Parameter(String, DbType)

Initializes a new instance of the Parameter class, using the specified name and database type.

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

Parameters

name
String

The name of the parameter.

dbType
DbType

The database type of the parameter.

Remarks

A Parameter object created with the Parameter(String, DbType) constructor is initialized with the specified name and dbType parameters, and with default values for other properties. The Direction property is initialized to Input, and the DefaultValue property is initialized to null.

Applies to

Parameter(String, TypeCode)

Initializes a new instance of the Parameter class, using the specified name and type.

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

Parameters

name
String

The name of the parameter.

type
TypeCode

A TypeCode that describes the type of the parameter.

Examples

The following code example demonstrates how to call the Parameter(String, TypeCode) constructor from a class that extends the Parameter class to initialize the Name and Type properties of the instance. This code example is part of a larger example provided for the Parameter class overview.

// The StaticParameter(string, TypeCode, object) constructor
// initializes the DataValue property and calls the
// Parameter(string, TypeCode) constructor to initialize the Name and
// Type properties.
public StaticParameter(string name, TypeCode type, object value) : base(name, type) {
  DataValue = value;
}
' The StaticParameter(string, TypeCode, object) constructor
' initializes the DataValue property and calls the
' Parameter(string, TypeCode) constructor to initialize the Name and
' Type properties.
Public Sub New(name As String, type As TypeCode, value As Object)
   MyBase.New(name, type)
   DataValue = value
End Sub

Remarks

A Parameter object created with the Parameter(String, TypeCode) constructor is initialized with the specified name and type parameters, and default values for other properties. The Direction property is initialized to Input, and the DefaultValue property is initialized to null.

See also

Applies to

Parameter(String, DbType, String)

Initializes a new instance of the Parameter class, using the specified name, the specified database type, and the specified value for its DefaultValue property.

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

Parameters

name
String

The name of the Parameter instance.

dbType
DbType

The database type of the Parameter instance.

defaultValue
String

The default value for the Parameter instance, if the Parameter is bound to a value that is not yet initialized when Evaluate(HttpContext, Control) is called.

Remarks

The Direction property of the Parameter instance is initialized to Input.

Applies to

Parameter(String, TypeCode, String)

Initializes a new instance of the Parameter class, using the specified name, the specified type, and the specified string for its DefaultValue property.

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

Parameters

name
String

The name of the parameter.

type
TypeCode

A TypeCode that describes the type of the parameter.

defaultValue
String

A string that serves as a default value for the parameter, if the Parameter is bound to a value that is not yet initialized when Evaluate(HttpContext, Control) is called.

Remarks

A Parameter object created with the Parameter(String, TypeCode, String) constructor is initialized with the specified name parameter and type parameter, and assigned a DefaultValue property value. The Direction property is initialized to Input.

See also

Applies to