Language preference:

Phase 3 / The BLDPageManager control and DataBound Control Adapters

A BLDPageManager control is required on any page that uses Peter’s Business Logic Driven UI.

The BLDPageManager control connects your DataBound controls (GridView, BLDFormView, etc) to the BLD framework. Its primary tool is the DataBound Control Adapter classes that are added to its Adapters property. Each DataBound Control must have an associated DataBound Control Adapter.

<des:BLDPageManager ID="BLDPageManager1" runat="server" >
    <des:BLDListViewAdapter DataBoundControlID="BLDListView1" />

The DataBound Control Adapters are loaded with functionality. Here are some of the tasks handled by DataBound Control Adapters:

  • Attaching and handling events on the DataBound control that are specific to BLD. Many events always do the same thing when creating data oriented views, so why should you write that code, and do it repeatedly for each case?
  • Creates a Master-detail relationship between a list and detail DataBound control.
    <des:BLDPageManager ID="BLDPageManager1" runat="server" >
          <des:BLDListViewAdapter DataBoundControlID="BLDListView1" ConnectedToControlID="BLDFormView1"/>" 
          <des:BLDFormViewAdapter DataBoundControlID="BLDFormView1" ConnectedToControlID="BLDListView1" />" 
  • Customize how Automatic Scaffolding works.
  • Connects to the ValidationSummary control that reports errors.
  • Determines which command buttons should appear. (For example, it only shows the Edit button when the DataSource.EnableUpdate or its own SupportsEditAction property allows it.)
  • Determines how to respond to a command, such as redirecting to a URL or changing the DataBound control’s mode. You might specify URLs for commands like Save, Cancel, New and Edit, or let ASP.NET URL Routing take care of it.
<des:BLDPageManager ID="BLDPageManager1" runat="server" >
    <des:BLDFormViewAdapter DataBoundControlID="RecordDetails" 
      SupportsEditActions="false" SupportsInsertActions="true" 
      ActionsUseRouting="true" PostInsertAction="List" PostCancelAction="List" />

The BLDPageManager control has numerous event handlers. While they may not mean much now, know that when you want to modify something at runtime, check out the BLDPageManager's events.

  • ResolveDataField – You can define DataField names that do not exist in your Entity class. This event is called to determine how to handle those custom DataFields. It allows you to create content based on anything available to your Web Form (such as query strings, form fields, and of course the Entity) that will be shown by a Field Template. Deep Dive
  • FieldTemplateLoad - Edit the initial settings of a Field Template object. Attach event handlers to its DataControl, such as the TextChanged event of a TextBox.
  • FieldTemplatePreRender - Adjust the final look of the controls within the Field Template object.
  • CustomizeDataField - Override the values supplied by business logic for each DataField. Add UI specific validators, change DisplayName and other textual properties, and edit many of the other DataAnnotations.
  • MakeActionUrl – Prepares the URL used to redirect to another page upon completing a List, Detail, Insert, or Edit command.
  • UpdateErrorMessage – Gives you a chance to change the error messages returned when your business logic reports validation errors.
  • PrepareSummaryText - Modify the text returned by EntityFilters that attempt to describe themselves in a user friendly way. This text in shown as EntityFilters are applied by the BLDFilterSummary control and, BLDFilterField control when its DisplayMode = Summary.
  • CustomizeButton - Modify the text shown by the BLDFilterSummary control and, BLDFilterField control when its DisplayMode = Summary.
  • DataBoundControlAdapterInitialized - Be notified when you can start using the DataBoundControlAdatper object to customize your user interface.
One challenge when working with a prepared library for UI development is that its not flexible. This is made worse by having business logic dictate so much and the UI's reliance on Template files. These event handlers are some solutions to these issues built into BLD. BLD's goal is to let you develop the exact user interface you want.

In the next topic, you'll learn about the BLDCustomizer control.