Form Template

Topic updated 17-10-2007

The Form Template is a Databound Control Template that displays a single object/row in form layout. The Form Template operates in multiple modes that  depend on Action Templates that call the form with certain actions:

View Action - data is displayed read-only
Insert Action - opens an empty form to add a new object/row
Change Action - loads an existing object/row into the form for editing and updating

 

Field label texts displayed by the Form Template can be configured in the Database Repository, using the Column configuration page, or the Mass Column Editor.

The selection of fields displayed by the Form Template is determined through its DataSource Configuration.

 

Form Template Features

Main features of the Form Template:

Based on standard ASP.NET 2.0 server controls FormView, DetailsView and ObjectDataSource.
Standard ASP.NET 2.0 databinding to a Factory Class generated with the NHibernate Templates (BO-Layer project).
Uses configurable Action Templates for actions such as Save and Cancel.
Configure form fields and behaviour with Browse Property Templates.

 

Form implementation

To be able to determine what object to load the Form Template uses the http query string as mechanism of passing the Primary Key. Consequently, a primary key is required to use the Form Template on an entity.

The main difference between DetailsView and FormView is that DetailsView has a built-in tabular rendering, whereas FormView requires a user-defined template for its rendering, and is more flexible. The FormView and DetailsView object model are very similar otherwise.

 

The GenWise ASP.NET Wizard will automatically include lookups (parent relationship) to resolve 3rd Normal Form (Foreign Keys). Read the Wizard topic to understand how you can configure this option.

 

Field Priming

A common scenario is that you want to set default values for some form fields when it is used in insert mode. The Form Priming User CodeBlock can be used to assign default values when the form is in insert mode.

FormsFieldPriming

 

If the default value does not depend on the user interface, the ASP.NET project is not the proper place to assign it. In that case it is recommended to instead use Initialization of properties in the POCO class.

 

See also

Use DataSource Configuration to determine which fields are displayed by the Form Template.

The ASP.NET Wizard connects browse pages (pages with the Browse Template) correctly to form pages automatically by default.