DataType DataType DataType 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

CreditCard CreditCard CreditCard CreditCard 14

Represents a credit card number.

Currency Currency Currency Currency 6

Represents a currency value.

Custom Custom Custom Custom 0

Represents a custom data type.

Date Date Date Date 2

Represents a date value.

DateTime DateTime DateTime DateTime 1

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

Duration Duration Duration Duration 4

Represents a continuous time during which an object exists.

EmailAddress EmailAddress EmailAddress EmailAddress 10

Represents an email address.

Html Html Html Html 8

Represents an HTML file.

ImageUrl ImageUrl ImageUrl ImageUrl 13

Represents a URL to an image.

MultilineText MultilineText MultilineText MultilineText 9

Represents multi-line text.

Password Password Password Password 11

Represent a password value.

PhoneNumber PhoneNumber PhoneNumber PhoneNumber 5

Represents a phone number value.

PostalCode PostalCode PostalCode PostalCode 15

Represents a postal code.

Text Text Text Text 7

Represents text that is displayed.

Time Time Time Time 3

Represents a time value.

Upload Upload Upload Upload 16

Represents file upload data type.

Url Url Url Url 12

Represents a URL value.

Examples

The following example uses the ttribute 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:

  • Implements a metadata partial class for the related table and the associated metadata class.

  • Applies the ttribute attribute to the EmailAddress data field by specifying the EmailAddress enumerated value in the associated metadata class. This indicates to the Text.ascx field template that the email address display is customized.

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
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:

  • Visual Studio 2008 Service Pack 1 or Visual Developer 2008 Express Edition Service Pack 1.

  • The AdventureWorksLT sample database. For information about how to download and install the SQL Server sample database, see Microsoft SQL Server Product Samples: Database. Make sure that you install the correct version of the sample database for the version of SQL Server that you are running (SQL Server 2005 or SQL Server 2008).

  • A Dynamic Data Web site. This enables you to create a data context for the database and the class that contains the data field to customize and the methods to override. In addition, it creates the environment in which to use the page described before. For more information, see Walkthrough: Creating a New Dynamic Data Web Site Using Scaffolding.

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

Remarks

This enumeration is used to specify the type of data to associate with a data column or a parameter. You use the ttribute 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 ttribute 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 type. This information can be accessed by the field templates and modify how the data field is processed.

The following table lists the data types Dynamic Data provides.

Applies to

See Also