Home     About PeterBlum.com     Policies     Download a Licensed Product     Newsletter

DES Dynamic Data
Improving PageTemplates

The PageTemplate is a web form that includes the primary controls for Dynamic Data: a DataSource, DataBound Control, and DynamicDataManager to display the contents of a table. They are located in the [web app]/DynamicData/PageTemplates folder. There are separate web forms for each of these actions: Details, Edit, Insert, List, and List+Details. They are table and data field agnostic. They acquire the table from ASP.NET URL Routing (such as /Products/Edit.aspx). They acquire the data fields from automatic scaffolding.

PageTemplates are a specialized way to use Dynamic Data within your web forms. With PageTemplates, you can create a fully operational database exploration application representing all tables and columns that are declared in your Data Context.

DES Dynamic Data simplifies and enhances PageTemplates in several ways:

  • The GridView has been replaced by DynamicListView; DetailsView has been replaced by DynamicFormView. These DES-specific Databound controls use PatternTemplates to allow complete control over the HTML generated. They also support automatic scaffolding, so they are easy to setup.
  • PageTemplates showing lists use the DynamicControlPanel control to provide feature rich paging and other page manipulation tools, like sorting, and the number of records shown.
  • Event handler methods attached to the DataBound controls have disappeared. They are now internal to DES's DynamicDataManager control. As you edit PageTemplates, you do not have to worry about bugs created by incorrectly setup event handlers or code lost during editing because that code is in a separate compiled class.
  • You can entirely abandon using the CustomPages folder for PageTemplates by implementing the IFieldGeneratorGuidance interface on the Master Page. Your MasterPage will generate the exact list of data fields you want for each table, or let automatic scaffolding create the list from your business rules.

    This solves several key problems:
    • Keeping the formatting of your main PageTemplate in sync with the table specific PageTemplate in the CustomPages folder. You no longer have to remember to update more than one web form.
    • Defining lists of data fields based on the individual situation. For example, when a user's role dictates, omit certain data fields.
    • Your code for IFieldGeneratorGuidance can specify alternative interfaces and change the defaults on FieldTemplate properties to get different behaviors.
  • Customize the DataBound control's properties and events at runtime by implementing the ICustomizeDataBoundControl interface in your Master Page. This avoids modifying the actual PageTemplates to handle individual situations.
  • Elimination of code behind files. While code behind has a purpose, when you need to duplicate web forms, they can cause problems, especially with regard to namespaces. Many times you end up with two web forms that have the same class and namespace, causing compilation errors.