Databases Reference
In-Depth Information
NOTE
Creating the UnleashedEntity control just for the sake of initializing its UIHint might
seem excessive compared to other, simpler ways you could encapsulate this functional-
ity. However, there are other reasons to extend this control as well. Recall the capability
implemented in the UnleashedControl to inherit its Mode property from the parent
entity template. The UnleashedEntity control implements similar logic, which enables
using generic templates discussed in Chapter 4 inside of multimode templates from
Chapter 10 without having to implement additional initialization. Refer to the source
code accompanying this topic to see how this was accomplished.
With all four page templates modified to use the UnleashedEntity instead of the
DynamicEntity control, you now have support for metadata-driven entity UI hints in your
Dynamic Data web application and can begin implementing additional form layouts as in
separate dynamic entity templates.
Building a Dynamic Two-Column Entity Template
As you might recall, the idea of the two-column entity template is that you specify the
name of the column where you want a particular property to display using the GroupName
property of the DisplayAttribute applied to it in the metadata. In the following code
snippet, the FirstName and LastName properties need to be in the column called “ Left ”,
and the Address and City properties need to be in the column called “ Right ”. The job of
the TwoColumn entity template is to define these two columns and instantiate the dynamic
controls and their labels in the appropriate column, based on the GroupName annotation:
[MetadataType(typeof(Metadata))]
partial class Employee
{
[EntityUIHint(“TwoColumn”)]
private abstract class Metadata
{
[Display(GroupName = “Left”, Order = 100)]
public object FirstName { get; set; }
[Display(GroupName = “Left”, Order = 110)]
public object LastName { get; set; }
[Display(GroupName = “Right”, Order = 200)]
public object Address { get; set; }
[Display(GroupName = “Right”, Order = 210)]
public object City { get; set; }
}
}
 
Search WWH ::




Custom Search