Web page development frequently uses patterns, such as the HTML for a table row with two columns, where the first column contains a field name and the other is the field’s data.
In fact, the previous topic used this pattern with each DataField in the BLDFormView:
<tr class="DetailsViewDataFieldRow" >
<td class="DetailsViewLabelContainer">
<des:BLDLabel id="Label1" runat="server" AssociatedControlID="BLDDataField1" />
</td>
<td class="DetailsViewDataContainer">
<des:BLDDataField id="BLDDataField1" runat="server" DataField="column name" />
</td>
</tr>
You can save these patterns into User Control files called Pattern Templates. They usually contain
a BLDDataField control
and sometimes a BLDLabel control. These controls will not have
their DataField property assigned yet. Instead, the Pattern Template file works with
your DataBound control to retrieve the DataField name.
for the contents around your Field Templates.
Here is a Pattern Template file that implements the above pattern. It only needs
to omit the DataField property on BLDDataField and specify the correct ancestor class.
<%@ Control Language="C#" Inherits="PeterBlum.DES.BLD.DataFieldsPatternTemplate" Usage="Data" %>
<tr class="DetailsViewDataFieldRow" >
<td class="DetailsViewLabelContainer">
<des:BLDLabel id="Label1" runat="server" AssociatedControlID="BLDDataField1" />
</td>
<td class="DetailsViewDataContainer">
<des:BLDDataField id="BLDDataField1" runat="server" />
</td>
</tr>
The above shows how a Pattern Template handles a single DataField. They can be much more
sophisticated. The "Parts Pattern Template" hosts numerous patterns, not just
for the BLDDataField "Parts", but also for the header, footer, row separator,
and HTML container around everything.
In the BLD Database Explorer, we've been using this type of Pattern Template.
The DetailsView.ascx Pattern Template mimics the appearance of a DetailsView control
and is used by default with the BLDFormView control.
The GridView.ascx Pattern Template mimics the appearance of the GridView control
and is used by default with the BLDListView control. Unlike the GridView and DetailsView,
the layout is fully editable as its layout is in a User Control file.
Pattern Templates can handle non-data oriented cases. For example, the Filter user interface
uses them.
Use the Source Code Browser to explore all Pattern Templates described here,
plus a few more.
- One Field TableRow.ascx - Use when showing a DataField and its label. It is the
actual implementation of the Pattern Template we mocked up above.
- Two Fields Stacked.ascx - Shows one or two DataFields, each with its own label.
- ButtonsForList.ascx - Handles the buttons used in a list style interface.
Its primary contents are the BLDDataButtons control with surrounding HTML to
describe table cell.
In the next topic, you will
learn how to assign the DataField to the BLDDataField contained in the Pattern Template.
Open the Source Code Browser (C# only)