Databases Reference
In-Depth Information
FIGURE 4.3
Supplier Information page produced by dynamic entity template.
Listing 4.10 shows the markup of the dynamic entity template.
LISTING 4.10
Default Entity Template (Markup)
<%@ Control Language=”C#” CodeBehind=”Default.ascx.cs”
Inherits=”WebApplication.DynamicData.EntityTemplates.DefaultEntityTemplate” %>
<asp:EntityTemplate runat=”server” ID=”entityTemplate”>
<ItemTemplate>
<tr>
<td>
<asp:Label runat=”server” OnInit=”Label_Init” />
</td>
<td>
<asp:DynamicControl runat=”server” OnInit=”DynamicControl_Init” />
</td>
</tr>
</ItemTemplate>
</asp:EntityTemplate>
Dynamic entity templates take advantage of the metadata information provided by
Dynamic Data, which includes the list of all columns for each table in the registered data
model. The
EntityTemplate
control used in this markup is a lightweight template control,
similar to the ASP.NET
Repeater
. The
OnLoad
method shown in Listing 4.11 uses it to
create a
Label
and a
DynamicControl
for each entity column programmatically. Because
the same template is used for all columns, the
DataField
property of the
DynamicControl
as well as the
Text
property of the
Label
is initialized programmatically in their respective
OnInit
event handlers.