DataTypeAttribute 建構函式

定義

初始化 DataTypeAttribute 類別的新執行個體。

多載

DataTypeAttribute(DataType)

使用指定的型別名稱來初始化 DataTypeAttribute 類別的新執行個體。

DataTypeAttribute(String)

使用指定的欄位範本名稱,來初始化 DataTypeAttribute 類別的新執行個體。

DataTypeAttribute(DataType)

使用指定的型別名稱來初始化 DataTypeAttribute 類別的新執行個體。

public:
 DataTypeAttribute(System::ComponentModel::DataAnnotations::DataType dataType);
public DataTypeAttribute (System.ComponentModel.DataAnnotations.DataType dataType);
new System.ComponentModel.DataAnnotations.DataTypeAttribute : System.ComponentModel.DataAnnotations.DataType -> System.ComponentModel.DataAnnotations.DataTypeAttribute
Public Sub New (dataType As DataType)

參數

dataType
DataType

要與資料欄位產生關聯的類型名稱。

範例

下列範例示範如何使用 建 DataTypeAttribute(DataType) 構函式來指定資料欄位的替代類型。

// Add type information.
[DataType(DataType.EmailAddress)]
public object EmailAddress;
' Add type information.
<DataType(DataType.EmailAddress)> _
Public EmailAddress As Object

備註

名稱是 列舉所 System.ComponentModel.DataAnnotations.DataType 定義的其中一個值。

適用於

DataTypeAttribute(String)

使用指定的欄位範本名稱,來初始化 DataTypeAttribute 類別的新執行個體。

public:
 DataTypeAttribute(System::String ^ customDataType);
public DataTypeAttribute (string customDataType);
new System.ComponentModel.DataAnnotations.DataTypeAttribute : string -> System.ComponentModel.DataAnnotations.DataTypeAttribute
Public Sub New (customDataType As String)

參數

customDataType
String

要與資料欄位產生關聯的自訂欄位範本名稱。

例外狀況

customDataTypenull 或空字串 ("")。

備註

這個方法提供使用 屬性的 UIHintAttribute 替代方法。

適用於