Home     About PeterBlum.com     Policies     Download a Licensed Product     Newsletter

DES Dynamic Data
The DynamicFormView control: Replacement for both DetailsView and FormView
Back

The DynamicFormView control is the recommended DataBound control for single record-style interfaces within DES Dynamic Data. While you can also use the DetailsView and FormView controls for these interfaces, both have limitations that are overcome by the DynamicFormView control.

Quality DetailsView FormView DynamicFormView
Easy to setup Very easy Difficult Very easy
Ability to customize HTML Minimal Complete Complete
Supports automatic scaffolding Yes No Yes

DynamicFormView is really a blend of the FormView control with PatternTemplates. It subclasses from System.Web.IU.WebControls.FormView. As a result, it has every feature of FormView. Internally, it populates all of the Templates found on FormView with PatternTemplates. You provide a list of data fields to the DynamicFormView (optionally using scaffolding) and it builds the HTML output by connecting each data field name to the controls defined in the PatternTemplate.

If needed, you can switch to declaring controls directly in its Templates, making it return to its FormView roots.

The default DynamicFormView control uses the DetailsView.ascx PatternTemplate file which mimics the appearance of the DetailsView control. Create your own PatternTemplates to address your specific formatting.

<desDD:DynamicFormView ID="DynamicFormView1" runat="server" DataSourceID="DetailDataSource" >
</desDD:DynamicFormView>
The most simple setup. It uses the DetailsView.ascx PatternTemplate and automatic scaffolding.

<desDD:DynamicFormView ID="DynamicFormView1" runat="server" DataSourceID="DetailsDataSource" PatternTemplateName="MyCustomTemplate">
  <ItemsInPattern>
    <desDD:DataFieldInPattern DataField="ProductName" />
    <desDD:DataFieldInPattern DataField="UnitPrice" />
    <desDD:DataFieldInPattern DataField="QuantityPerUnit" />
    <desDD:DataFieldInPattern DataField="ReorderLevel" />
    <desDD:DataFieldInPattern DataField="UnitsInStock" />
    <desDD:DataFieldInPattern DataField="Discontinued" />
  </ItemsInPattern>
  <NamedStyles>
    <desDD:NamedStyle Name="LabelColumn" CssClass="FancyColumnNames" />
  </NamedStyles>
</desDD:DynamicFormView>
Using an alternative PatternTemplate and explicitly defining the list of data fields.

Back