Built-in Field Templates
Dynamic Data web project templates in Visual Studio 2010 include a large number of ready-to-use field templates.
Boolean
The Boolean.ascx field template is used for Boolean columns in Read-only mode. It contains a disabled CheckBox control, checked when the field value is true.
Boolean_Edit
The Boolean_Edit.ascx field template is used for Boolean columns in Edit and Insert modes. It contains a CheckBox control users can use to set field value to true or false. This field template does not support null values and, unlike other well-behaved field templates, does not perform validation.
Children
The Children.ascx field template is used in Read-only and Edit modes for navigation properties that represent the many side of one-to-many relationships between entities. For example, the Customer entity in the Northwind sample data model has a children navigation property called Orders, which returns a collection of all orders placed by a given customer. In Read-only and Edit modes, the Children.ascx entity template displays a hyperlink to the dynamic List.aspx page that displays all child rows of the parent entity.
Children_Insert
The Children_Insert.ascx field template is empty. Because the dynamic List.aspx page cannot display child rows of a parent entity that has not been submitted to the database, this template prevents the Children.ascx field template from being used in Insert mode.
DateTime
The DateTime.ascx field template is used in Read-only mode to display DateTime field values. This field template contains a Literal control that injects the field value directly into the web page without any adorning HTML elements. This template is nearly identical to the Text.ascx template described in the following sections and could be removed, making Text.ascx responsible for displaying DateTime field values in Read-only mode as well.
DateTime_Edit
The DateTime_Edit.ascx field template is used for DateTime columns in Edit and Insert mode. It contains a TextBox control, accompanied by a CustomValidator, used to make sure that the value entered in the TextBox is a valid DateTime. It also contains a RequiredFieldValidator, used to enforce values for columns marked with the RequiredAttribute, a RegularExpressionValidator, used to enforce regular expression patterns for columns marked with the RegularExpressionAttribute and a DynamicValidator, used to enforce all other validation attributes applied to this column.
Decimal_Edit
The Decimal_Edit.ascx field template is used for Decimal, Float, and Double columns in Edit and Insert mode. It contains a TextBox control, accompanied by a CompareValidator, used to ensure that values entered in the TextBox are valid numbers. It also contains a RequiredFieldValidator, used to enforce values for columns marked with the RequiredAttribute; a RangeValidator, used to enforce range of values for columns marked with the RangeAttribute; a RegularExpressionValidator, used to enforce regular expression patterns for columns marked with the RegularExpressionAttribute; and a DynamicValidator, used to enforce all other validation attributes applied to this column.
EmailAddress
The EmailAddress.ascx field template is a read-only template used for String columns marked with the DataType(DataType.EmailAddress) attribute. It includes a HyperLink control that displays the field value as a link with the URL scheme "mailto:". When the user clicks this link, most web browsers launch the default e-mail client installed on the computer and create a new message with the field value automatically added in the “To” list.
Enumeration
The Enumeration.ascx field template is used for enumeration columns in Read-only mode. It contains a Literal control that displays the underlying integral field value converted to its equivalent enumerated value and then converted to a String.
Enumeration Edit
The Enumeration_Edit.ascx field template is used for enumeration columns in Edit and Insert modes. It contains a DropDownList control, populated with enumerated items converted to string, plus “[Not Set]” if the column allows null values. This field template also includes a RequiredFieldValidator to enforce values for columns marked with the RequiredAttribute and a DynamicValidator to enforce all other validation attributes applied to this column.
ForeignKey
The ForeignKey.ascx is used for foreign key columns in Read-only mode. It contains a HyperLink control that displays the field value of the “display” column of the parent table. You can specify the display column explicitly by applying the DisplayColumnAttribute to the parent entity class, or it can be selected automatically based on the Dynamic Data heuristics. Users can click the link generated by the control to navigate to the List.aspx page of the parent table.
ForeignKey_Edit
The ForeignKey_Edit.ascx field template is used for foreign key columns in Edit and Insert modes. It contains a DropDownList control that displays all rows from the parent table. The display column of the parent table determines the Text of each ListItem, and its primary key columns determine its Value.
Integer_Edit
The Integer_Edit.ascx field template is used for Byte, Int16, Int32, and Int64 columns in Edit and Insert modes. It contains a TextBox control, accompanied by a CompareValidator, which is used to ensure that values entered in the TextBox are valid numbers. It also contains a RequiredFieldValidator, used to enforce values for columns marked with the RequiredAttribute; a RangeValidator, used to enforce range of values for columns marked with the RangeAttribute; a RegularExpressionValidator, used to enforce regular expression patterns for columns marked with the RegularExpressionAttribute; and a DynamicValidator, used to enforce all other validation attributes applied to the column.
ManyToMany
The ManyToMany.ascx field template is used for children columns in a many-to-many relationship, such as the Employees column of the Territory entity in the Northwind sample database. This template contains a Repeater control that generates a DynamicHyperLink for every child entity. On the actual page, this looks like a list of hyperlinks that the user can click to navigate to the Details.aspx page of a particular child entity.
ManyToMany_Edit
The ManyToMany_Edit.ascx field template is used for many-to-many children columns in Edit and Insert modes. This template contains a CheckBoxList control that generates a check box for every entity the user can check to add it to the list of children.
MultilineText_Edit
The MultilineText_Edit.ascx field template is used for long string columns in Edit and Insert modes. It contains a TextBox control with TextMode property set to MultiLine. It also contains a RequiredFieldValidator, used to enforce values for columns marked with the RequiredAttribute, a RegularExpressionValidator, used to enforce regular expression patterns for columns marked with the RegularExpressionAttribute and a DynamicValidator, used to enforce all other validation attributes applied to the column.
String columns are considered long when they do not have maximum length specified in the data model, such as the Notes column of the Employee entity in the Northwind sample, which has type NTEXT. You can also force Dynamic Data to use the MultilineText_Edit field template for columns that do have maximum length by applying the DataType(DataType.MultilineText) attribute to their properties in the data model.
Text
Due to the data type fallback used during template lookup, the Text.ascx field template can be used in Read-only mode for columns of all primitive types with the exception of Boolean and DateTime columns, for which Dynamic Data provides specific templates. This field template includes a Literal control that displays the field value converted to a string.
Text_Edit
The Text_Edit.ascx field template is used for string columns in Edit and Insert modes. It includes a TextBox control, accompanied by a RequiredFieldValidator, used to enforce values for columns marked with the RequiredAttribute; a RegularExpressionValidator, used to enforce regular expression patterns for columns marked with the RegularExpressionAttribute; and a DynamicValidator, used to enforce all other validation attributes applied to the column.
Url
The Url.ascx field template is used for columns marked with the DataType(DataType.Url) attribute. It contains a HyperLink control that displays the field value as a link in the generated HTML. The "http://" scheme is automatically added to the URL unless the field value already contains it. Only HTTP and HTTPS schemes are recognized automatically. Although this field template does not require the column type to be only String, the field value converted to string must be a valid URL for the generated hyperlink to work correctly.