Wednesday 10 February 2010

Asp.Net Dynamic Data – UI Hint Part 1

The UIHint attribute allows you to tell Dynamic Data what field template you would like to use when working with the property.

Before I get ahead of myself lets briefly cover Field Templates.  A field template is what dynamic data uses to display the value for a data field.   Each field template is implemented as a normal Asp.Net user control which contains the basic UI definition and validation.  You can easily create your own custom field templates to provide the display or functionality you need.

What the UIHint attribute allows you to do is to specify the field template that you wish to use for a particular field/property on the table.

By doing this you override the default behaviour of dynamic data which normally decides the field template to use based on the data type of the field.

[UIHint("DateTime")]
public object ShippedDate { get; set;}

Doing this ensures that when ShippedDate is displayed in a list, detail or edit it is the DateTime field template that will be used.

No comments:

Post a Comment