How Dynamic Data changes how you build web forms
Back
ASP.NET Dynamic Data emphasizes “separation of concerns” where business logic is
separated from the web form. In addition, the web controls showing and validating
data are shared by all web forms, providing a consistent user interface. It internally
handles database interaction, so you don’t have to write code to create, read, update,
or delete records (often known as “CRUD”).
In traditional ASP.NET web forms, the web form developer must setup every web control,
including the right validators, leaving a potential of saving data that does not
match your business logic. There is also the potential of creating a different look-and-feel
on fields that are the same datatype. The database interaction is written into each
form.
Separation of Concerns
Here are the elements separated out by ASP.NET Dynamic Data:
- Business logic – Rules for validation and other aspects of managing data on an
individual column are kept within a file specific to your business logic. The web
form developer never creates controls or code to handle this.
- FieldTemplates – User interface for displaying and editing the data types used
by columns in your database. These are actually UserControls, subclassed from Dynamic Data’s FieldTemplateUserControl class. Each FieldTemplate
handles a single data type, such as date and integer. Your web app will have a library
of FieldTemplates. There can be several FieldTemplate files for a single data type
in your library, offering you different ways to display and edit that data type.
- Web Forms – The standard workspace for displaying HTML is still used to present
the columns of your database. It still uses typical web controls, like Labels, Buttons,
MultiViews, etc. When you need to show a column from your database, include a DynamicField
or DynamicControl web control with the name of the column in its DataField property.
ASP.NET Dynamic Data internally converts that web control into the right FieldTemplate
and applies the business logic to it.
Alternatively, let the automatic scaffolding
feature populate your DataBound control with a list of columns, following the rules
defined in the business logic.
- DataSources – Code to create, read, update and delete records (“CRUD”). ASP.NET
Dynamic Data relies on special DataSource controls, such as LinqDataSource or EntityDataSource, that are placed on the Web Forms.
Developers Play Different Roles
Due to separation of concerns, you have several developer roles
to fill:
- Database developer – Creates the business logic by assigning
attributes and code to the classes that dictate the business
logic of each table and column, including validation rules.
- FieldTemplate developer – Builds the FieldTemplate UserControls. These are
a smart user interface specific to a single
type of data, including readonly and editable modes, complete with validators.
- Web form developer – Defines the data fields shown and their layout on the page.
By using PageTemplates, the web form developer has most of the work done.
Dynamic Data combines these elements through these controls found on the web forms:
your Databound Control (GridView, ListView, DynamicListView, DetailsView, FormView, or DynamicFormView) and the DynamicControls they contain, the DynamicDataManager, and your DataSource.
Back
|