Language preference:

Phase 4 / BLDLabel control: Showing text from the BLL

The BLDLabel control is a subclass of the native Label that can populate its text using the textual metadata from a DataField. It typically shows the DisplayName or ShortDisplayName from the DESDA.DisplayNameAttribute.

You can specify the DataField name in its DataField property. It knows the Entity class for that DataField by looking at the containing DataBound control. Alternatively, you can point its AssociatedControlID property to the BLDDataField control that it labels. It will determine the DataField from that.

<des:BLDLabel id="ProductNameLabel" runat="server" AssociatedControlID="ProductName" />
<des:BLDDataField id="ProductName" runat="server" DataField="ProductName" />

Use the LabelSource property to select the source from the Business Logic: DisplayName, ShortDisplayName, Description, or Prompt. The resulting text will be localized.

Use the Source Code Browser to see examples of each DataBound control using these objects.

In the next topic, you will learn about Pattern Templates.



Open the Source Code Browser (C# only)
Source Code Browser
 
<%Control Language="C#" AutoEventWireup="true" %>
<des:BLDPageManager ID="BLDPageManager1" runat="server" AutoLoadForeignKeys="true">
   <Adapters>
      <des:BLDFormViewAdapter DataBoundControlID="BLDFormView1" SupportsEditActions="false" SupportsInsertActions="false" />
   </Adapters>
</des:BLDPageManager>
<asp:UpdatePanel id="UpdatePanel1" runat="server">
   <ContentTemplate>
      <des:BLDFormView ID="BLDFormView1" runat="server" 
         DataSourceID="DataSource1" DataKeyNames="ProductID" AllowPaging="True"
         AutoGenerateButtons="None" ShowFooterRow="true" AutoScaffold="No" >
         <ItemTemplate>
            <table class="DetailsViewContainer">
               <tr class="DetailsViewDataFieldRow">
                  <td class="DetailsViewLabelContainer">
                     <des:BLDLabel ID="BLDLabel1" runat="server" AssociatedControlID="ProductNameLabel" />
                  </td>
                  <td class="DetailsViewDataContainer">
                     <des:BLDDataField ID="ProductNameLabel" runat="server" DataField="ProductName" />
                  </td>
               </tr>
               <tr class="DetailsViewDataFieldRow">
                  <td class="DetailsViewLabelContainer">
                     <des:BLDLabel ID="BLDLabel2" runat="server" AssociatedControlID="UnitPriceLabel" />
                  </td>
                  <td class="DetailsViewDataContainer">
                     <des:BLDDataField ID="UnitPriceLabel" runat="server" DataField="UnitPrice" />
                  </td>
               </tr>
               <tr class="DetailsViewDataFieldRow">
                  <td class="DetailsViewLabelContainer">
                     <des:BLDLabel ID="BLDLabel3" runat="server" AssociatedControlID="CategoryLabel" />
                  </td>
                  <td class="DetailsViewDataContainer">
                     <des:BLDDataField ID="CategoryLabel" runat="server" DataField="Category" />
                  </td>
               </tr>
               <des:BLDWidgetsView id="BLDWidgetsView1" runat="server" ContainerTag="TableRowWithOneCell" />
            </table>
         </ItemTemplate>
         <PagerSettings Visible="false" />
      </des:BLDFormView>
   </ContentTemplate>
</asp:UpdatePanel>
<des:EntityDAODataSource ID="DataSource1" runat="server" 
   EntityTypeName="PeterBlum.WithDataAnnotations.Product"
   EnableUpdate="false" EnableInsert="false" EnableDelete="false" >
</des:EntityDAODataSource>