Home     About PeterBlum.com     Policies     Download a Licensed Product     Newsletter

DES Dynamic Data
The DynamicListView control: Replacement for both GridView and ListView
Back

The DynamicListView control is the recommended DataBound control for list-style interfaces within DES Dynamic Data. While you can also use the GridView and ListView controls for these interfaces, both have limitations that are overcome by the DynamicListView control.

Quality GridView ListView DynamicListView
Easy to setup Very easy Difficult Very easy
Ability to customize HTML Minimal Complete Complete
Supports automatic scaffolding Yes No Yes

DynamicListView is really a blend of the ListView control with PatternTemplates. It subclasses from System.Web.IU.WebControls.ListView. As a result, it has every feature of ListView. Internally, it populates all of the Templates found on ListView with PatternTemplates. You provide a list of data fields to the DynamicListView (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 ListView roots.

The default DynamicListView control uses the GridView.ascx PatternTemplate file which mimics the appearance of the GridView control. A second PatternTemplate file, ListOfDetailViews.ascx, shows each record in the style of the DetailsView control. Create your own PatternTemplates to address your specific formatting.

<desDD:DynamicListView ID="DynamicListView1" runat="server" DataSourceID="ListDataSource" >
</desDD:DynamicListView>
The most simple setup. It uses the GridView.ascx PatternTemplate and automatic scaffolding.

<desDD:DynamicListView ID="DynamicListView1" runat="server" DataSourceID="ListDataSource" PatternTemplateName="ListOfDetailViews">
  <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 DataField="QuantityPerUnit" Style="white-space:nowrap;" />
  </NamedStyles>
</desDD:DynamicListView>
Using an alternative PatternTemplate and explicitly defining the list of data fields.


Back