Databases Reference
In-Depth Information
Dynamic Data looks for custom page templates under
DynamicData\CustomPages
, in a
subfolder with the name that matches the name of the
MetaTable
describing its entity
type. Here is how the folder structure looks:
DynamicData
\CustomPages
\{Table1}
{Template1}.aspx
{Template2}.aspx
...
\{Table2}
{Template1}.aspx
{Template2}.aspx
...
...
\PageTemplates
{Template1}.aspx
{Template2}.aspx
...
To create a custom Details page template for the Order entity type, you need to create a
subfolder called
Orders
(note the plural form, as in the name of the table). Begin imple-
menting the custom page by copying the default
Details.aspx
page template from the
PageTemplates
folder to the newly created
CustomPages\Orders
folder. This gives you the
FormView
control that will display the Order information along with the
EntityDataSource
and
QueryExtender
controls it needs to be able to get the data from the database. The
second part of the page needs a
GridView
control to display Order Details plus its own
EntityDataSource
and
QueryExtender
controls. Finally, a
Literal
control to display the
order total calculated in the code-behind. Listing 6.10 shows the complete markup of the
new page.
LISTING 6.10
Custom Order Details Page Template (Markup)
<%@ Page Language=”C#”
MasterPageFile=”~/Site.master” CodeBehind=”Details.aspx.cs”
Inherits=”WebApplication.DynamicData.CustomPages.Orders.Details” %>
<asp:Content ContentPlaceHolderID=”main” runat=”Server”>
<asp:DynamicDataManager runat=”server”>
<DataControls>
<asp:DataControlReference ControlID=”formView” />
</DataControls>
</asp:DynamicDataManager>
<table>
<tr valign=”top”>
<td>