Databases Reference
In-Depth Information
As an example, consider Table 3.4, which shows the sequence of template file names
Dynamic Data will try when looking for a matching field template for the HomePhone
property of the Employee entity.
TABLE 3.4 Example of Field Template Lookup for String Column
Mode=“Insert”
Mode=“Edit”
Mode=“ReadOnly”
PhoneNumber_Insert.ascx
PhoneNumber_Edit.ascx
PhoneNumber.ascx
System.String_Insert.ascx
System.String_Edit.ascx
System.String.ascx
String_Insert.ascx
String_Edit.ascx
String.ascx
Text_Inser t.ascx
Text_Edit.ascx
Text.ascx
PhoneNumber_Edit.ascx
PhoneNumber.ascx
System.String_Edit.ascx
System.String.ascx
String_Edit.ascx
String.ascx
Text_Edit.ascx
Text.ascx
PhoneNumber.ascx
System.String.ascx
String.ascx
Text.ascx
Because the HomePhone property has no UIHintAttribute and UIHint property is not
specified for DynamicControl or DynamicField in page markup, the search sequence does not
include the file names based on the UIHint . However, the HomePhone property does have
the DataType specified in the data model using the [DataType(DataType.PhoneNumber)]
attribute.
In Insert mode, the FieldTemplateFactory checks to see if PhoneNumber_Insert.ascx ,
System.String_Insert.ascx , String_Insert.ascx , and Text_Insert.ascx field templates
exist before finding the PhoneNumber_Edit.ascx template created earlier in this chapter. If
this template didn't exist, the FieldTemplateFactory would continue checking for
System.String_Edit.ascx , String_Edit.ascx , and eventually find the Text_Edit.ascx
field template provided by Dynamic Data projects out of the box.
In Edit mode, the FieldTemplateFactory starts with PhoneNumber_Edit.ascx and because
it exists, uses it immediately. Likewise, had this field template not been defined, it would
continue the search and eventually find the Text_Edit.ascx template provided by
Dynamic Data.
In ReadOnly mode, the FieldTemplateFactory starts with PhoneNumber.ascx . Because the
read-only version of the phone number field template does not exist, it continues by
trying System.String.ascx and String.ascx and finally finds the Text.ascx field
template provided by Dynamic Data out of the box.
Table 3.5 shows another example of field template lookup sequence, this time for the
UnitsInStock property of the Product entity. This column is of type Int32 and, unlike the
HomePhone in the previous example, doesn't have a DataTypeAttribute applied to it.
Search WWH ::




Custom Search