Databases Reference
In-Depth Information
[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; }
}
}
Combined with the other annotations and several common types of form layouts, the
GroupName annotation enables you to continue evolving the entity model without having
to create custom entity and page templates even for larger entities, where a single-column
layout is no longer practical. However, as you might suspect based on this open-ended
description, the GroupName annotation is not supported by the Default entity template
that comes with the Dynamic Data project template. This section discusses how to imple-
ment additional dynamic entity templates and form layouts.
Extending Metadata to Support Entity UI Hints
Implementing multiple form layouts in a single dynamic entity template is usually not a
good idea. On one hand, making a single template responsible for more than one layout
would quickly make it too complex to maintain. On the other hand, you do not want to
risk breaking all existing dynamic forms by adding a new layout. Instead, it is better to use
separate entity templates for different layouts.
Specifying a particular entity template is easy when you are creating a custom page. All
you need to do is specify a UIHint attribute value for the DynamicEntity control, which
serves as the first candidate name when Dynamic Data searches for the matching entity
template. Chapter 4 showed how to take advantage of the UIHint attribute to reuse
generic templates for different entity types.
<asp:DynamicEntity runat=”server” UIHint=”Contact” />
However, there is no built-in capability in Dynamic Data to specify the UI hint in entity
metadata. You can solve this problem by defining your own data annotation, such as the
EntityUIHintAttribute in the sample solution, and changing the dynamic page templates
to initialize the UIHint property of the DynamicEntity control programmatically. Listing
11.11 shows the definition of the new attribute.
LISTING 11.11 EntityUIHintAttribute Implementation
using System;
namespace Unleashed.DataAnnotations
{
 
Search WWH ::




Custom Search