Databases Reference
In-Depth Information
Markup of the
TwoColumn
entity template is shown in Listing 11.13. By comparing this
markup with the Default entity template back in Listing 11.4, you can see that it has an
additional HTML
table
with two cells, each of them containing a nested
table
and an
ASP.NET
PlaceHolder
control, where the dynamically instantiated controls will be added,
depending on their
GroupName
annotation.
LISTING 11.13
TwoColumn Entity Template (Mar kup)
<%@ Control Language=”C#” CodeBehind=”TwoColumn.ascx.cs”
Inherits=”WebApplication.DynamicData.EntityTemplates.TwoColumnEntityTemplate” %>
<asp:EntityTemplate runat=”server” ID=”entityTemplate”>
<ItemTemplate>
<tr>
<td class=”DDLightHeader”>
<unl:UnleashedLabel runat=”server” OnInit=”Label_Init” />
</td>
<td>
<unl:UnleashedControl runat=”server” OnInit=”DynamicControl_Init” />
</td>
</tr>
</ItemTemplate>
</asp:EntityTemplate>
<table>
<tr>
<td style=”vertical-align:top”>
<table class=” DDDetailsTable”>
<asp:PlaceHolder runat=”server” ID=”left” />
</table>
</td>
<td style=”vertical-align:top”>
<table class=” DDDetailsTable”>
<asp:PlaceHolder runat=”server” ID=”right” />
</table>
</td>
</tr>
</table>
Listing 11.14 shows the code-behind file of the
TwoColumn
entity template with the differ-
ences from the default entity template shown in bold font. The main difference from the
default entity template is located in the
OnLoad
method of the
TwoColumnEntityTemplate
.
Notice how instead of adding the dynamically created controls to the
EntityTemplate
itself, it calls the
FindGroupPlaceHolder
method and adds them to the
PlaceHolder
control it returns. In other words, the Default entity template uses the
EntityTemplate
control as both a
template
to create the dynamic controls and a
container
to host them.
The
TwoColumn
template, however, uses the
EntityTemplate
control only as a template,
and the two
PlaceHolder
controls serve as containers for the generated controls.