Databases Reference
In-Depth Information
Composite Entity Templates
There is no requirement to have a single entity template per entity. You can create multi-
ple entity templates for a single entity, where each template contains presentation of the
entire entity or just a part of it. This is particularly useful for large entities, where it makes
sense to present the information on multiple pages or on multiple tabs of a single page.
You can further decompose the Customer entity template by separating contact and
address information into separate entity templates shown in Listing 4.6 and Listing 4.7,
respectively.
LISTING 4.6
Contact Entity Template (Markup)
<%@ Control Language=”C#” CodeBehind=”Contact.ascx.cs”
Inherits=”WebApplication.DynamicData.EntityTemplates.ContactTemplate” %>
<label>Name:</label>
<asp:DynamicControl runat=”server” DataField=”ContactName” />
<br />
<label>Company:</label>
<asp:DynamicControl runat=”server” DataField=”CompanyName” />
<br />
<label>Title:</label>
<asp:DynamicControl runat=”server” DataField=”ContactTitle” />
<br />
As you can see, the Contact entity template contains only name, company, and title
fields, and the Address entity template contains only the address fields.
LISTING 4.7
Address Entity Template (Markup)
<%@ Control Language=”C#” CodeBehind=”Address.ascx.cs”
Inherits=”WebApplication.DynamicData.EntityTemplates.AddressTemplate” %>
<fieldset><legend>Address</legend>
<label>Street:</label>
<asp:DynamicControl runat=”server” DataField=”Address” />
<br />
<label>City:</label>
<asp:DynamicControl runat=”server” DataField=”City” />
<label>State:</label>
<asp:DynamicControl runat=”server” DataField=”Region” />
<label>Zip:</label>
<asp:DynamicControl runat=”server” DataField=”PostalCode” />
</fieldset>
 
 
Search WWH ::




Custom Search