A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.datatype below:

DataType Enum (System.ComponentModel.DataAnnotations) | Microsoft Learn

DataType Enum Definition

Represents an enumeration of the data types associated with data fields and parameters.

public enum class DataType
public enum DataType
type DataType = 
Public Enum DataType
Inheritance
Fields Name Value Description Custom 0

Represents a custom data type.

DateTime 1

Represents an instant in time, expressed as a date and time of day.

Date 2

Represents a date value.

Time 3

Represents a time value.

Duration 4

Represents a continuous time during which an object exists.

PhoneNumber 5

Represents a phone number value.

Currency 6

Represents a currency value.

Text 7

Represents text that is displayed.

Html 8

Represents an HTML file.

MultilineText 9

Represents multi-line text.

EmailAddress 10

Represents an email address.

Password 11

Represent a password value.

Url 12

Represents a URL value.

ImageUrl 13

Represents a URL to an image.

CreditCard 14

Represents a credit card number.

PostalCode 15

Represents a postal code.

Upload 16

Represents file upload data type.

Examples

The following example uses the DataTypeAttribute attribute to customize the display of EmailAddress data field of the customer table in the AdventureWorksLT database. The email addresses are shown as hyperlinks instead of the simple text that ASP.NET Dynamic Data would have inferred from the intrinsic data type.

The example code:

using System;
using System.Web.DynamicData;
using System.ComponentModel.DataAnnotations;

[MetadataType(typeof(CustomerMetaData))]
public partial class Customer
{
}

public class CustomerMetaData
{

    // Add type information.
    [DataType(DataType.EmailAddress)]
    public object EmailAddress;
}
Imports System.Web.DynamicData
Imports System.ComponentModel.DataAnnotations

<MetadataType(GetType(CustomerMetadata))> _
Partial Public Class Customer


End Class

Public Class CustomerMetadata

    ' Add type information.
    <DataType(DataType.EmailAddress)> _
    Public EmailAddress As Object

End Class

To compile the example code, you need the following:

For the complete code example that the field template uses to customize the display of the EmailAddress data fields, see the DataTypeAttribute attribute.

This enumeration is used to specify the type of data to associate with a data column or a parameter. You use the DataTypeAttribute attribute class to specify the data type you want to associate with the data field or parameter. You select the data type from this enumeration.

The DataTypeAttribute attribute lets you mark fields by using a type that is more specific than the database intrinsic types. For example, a string data field that contains email addresses can be attributed with the EmailAddress enumerated value. This information can be accessed by the field templates and modify how the data field is processed.

See also

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this article

Was this page helpful?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4