Friday 12 February 2010

Asp.Net Dynamic Data – Data Type Part 1

When dynamic data is building the columns to display it works out the field template to use from the data type of the field it is going to display.

The data type attribute allows you to override what dynamic data wants to use with a more specific data type.
The standard data types supported are:


Data Type Description
DateTime Represents an instant in time, expressed as a date and time of day.
Date Represents a date value
Time Represents a time value
Duration Represents a continuous time during which an object exists.
PhoneNumber Represents a phone number value
Currency Represents a currency value
Text Represents text that is displayed.
Html Represents an HTML file
MultilineText Represents multi-line text.
EmailAddress Represents an e-mail address.
Password Represent a password value.
Url Represents a URL value.

As well as those listed another type of custom is supported allowing you to extend this functionality further yourself.

To use the DataType attribute you add the attribute to the display meta data:
[DataType(DataType.Date)]
public object OrderDate {get; set;}

This will then change the way the OrderDate field, a DateTime field, so that only the date is shown


2010-02-12_2133



The image shows the order date field with the DataType attribute set and the RequiredDate field that doesn’t.

No comments:

Post a Comment