Share via

ASP.NET Dynamic Data Overview

ASP.NET Dynamic Data is a framework that lets you create data-driven ASP.NET Web applications easily. It does this by automatically discovering data-model metadata at run time and deriving UI behavior from it. A scaffolding framework provides a functional Web site for viewing and editing data. You can easily customize the scaffolding framework by changing elements or creating new ones to override the default behavior. Existing applications can easily integrate scaffolding elements with ASP.NET pages.

This topic contains the following sections:

  • Introduction

  • Features

  • Background

  • Class Reference

  • Additional Information


You can use ASP.NET Dynamic Data to create new data-driven Web sites that require minimal code and that take full advantage of the capabilities of the Dynamic Data framework. You can also select specific Dynamic Data capabilities to add to existing Web sites.

Dynamic Data offers the following features:


The dynamic nature of Dynamic Data is that it can infer the appearance and the behavior of data fields from the underlying database schema at run time. This mechanism, together with the availability of default page and field templates and many possibilities for customization, gives you a variety of design choices, including the following:

  • Building a Web site using scaffolding.

  • Adding dynamic data to an existing Web site.

  • Adding data field validation business logic.

  • Customizing the UI that is rendered in order to display and edit specific data fields or a specific table.

Data Model

The data model represents the information that is in a database and how the items in the database are related to each other.

Dynamic Data supports the LINQ-to-SQL data model and the ADO.NET Entity Framework data model. You can include multiple instances of data models in a Web application, but the models that are used in Dynamic Data must be of the same type.

You register the data model or models that you want to use with Dynamic Data in the Web application's Global.asax file. After a data model is registered with Dynamic Data, the data model can perform automatic validation of data fields, and it lets you control appearance and behavior of data at the data layer level.


Scaffolding is a mechanism that enhances the existing ASP.NET page framework by dynamically displaying pages based on the data model. Scaffolding provides the following capabilities:

  • Minimal or no code to create a data-driven Web application.

  • Quick development time.

  • Built-in data validation based on the database schema.

  • Automatic data selection created for each foreign key or Boolean field.

Page Templates

Dynamic Data scaffolding uses page templates to provide a default view of data tables. Page templates are ASP.NET Web pages that are configured to display data from any table that is available to Dynamic Data. Dynamic Data includes page templates for different views of data, such as listing a table (List view), displaying master/detail tables (Details view), editing data (Edit view), and so on. By default, Dynamic Data is configured to use only a List view page template. You can change the default page template or change Dynamic Data to use different page templates for different purposes. For more information, see ASP.NET Dynamic Data Infrastructure.

Field Templates

Dynamic Data uses field templates to render the UI for displaying and editing individual data fields. It determines the appropriate field template from the data field types. Dynamic Data includes separate field templates for displaying and for editing data fields.

For example, for a DateTime data field Dynamic Data uses the following field templates:

  • DateTime.ascx. This template displays DateTime data type as text (a string) and renders it as a Literal control.

  • DateTime_Edit.ascx. This template renders a TextBox control. If the field in the database cannot be null or if the data model has been customized to require an entry, this control also renders a RequiredFieldValidator control. The DateTime_Edit.ascxfield template provides a DynamicValidator control that handles any exceptions that are thrown from the data model. It also supports the Regex class.

When you create a Dynamic Data Web project, Visual Studio adds a DynamicData\FieldTemplates folder to the project. This folder contains the default field templates.

You can customize the built-in field templates or create new ones in order to specify how individual data fields are rendered. For example, you can create field templates that render UI for displaying and editing telephone numbers or e-mail addresses. As another example, you can create field templates that render UI for using alternative ways (such as a slider) to let users specify numeric data.

Enhancing Existing Data Controls

Dynamic Data enhances existing data controls to include dynamic behavior in the following ways:

  • DetailsView and GridView controls can display data dynamically by using predefined Dynamic Data templates instead of requiring you to re-create the same markup and code for data controls in every page. You can customize these templates to change what controls to use and how to render the UI for displaying and editing data fields. This enables you to make changes in one location and affect the appearance and behavior of the data controls across the Web application. This is independent of the specific table, so that a page template can be used for any table in the database. For more information, see How to: Add Dynamic Behavior to Data-Bound Controls by Using a DynamicField.

  • FormView and ListView controls can implement behavior similar to that for DetailsView and GridView controls by using a DynamicControl control in their templates and by specifying which field in the row to display. Dynamic Data will then automatically build the UI for these controls, based on the templates that you specify. DynamicControl controls do not automatically render the UI for any field; you must bind the controls to a specific data field. For more information, see How to: Use ASP.NET Dynamic Data in Templated Data-Bound Controls.

  • Dynamic Data examines the data model metadata for a LINQ-to-SQL or Entity Framework data model and provides automatic validation based on the metadata. For example, if a column in the database is marked as not nullable, a RequiredFieldValidator control is automatically rendered for the column. You can also apply custom metadata in order to further customize how data fields are rendered and validated. For more information, see How to: Customize Data Field Validation in the Data Model.

Class Reference

The following table lists the namespaces that contain the ASP.NET Dynamic Data classes.




Provides attribute classes that are used to define metadata for Dynamic Data controls.


Contains classes that provide the core functionality for ASP.NET Dynamic Data. It also provides extensibility features to customize dynamic data behavior.

Additional Information

Suggestions for additional exploration include the following:

  • Understanding URL routing. For more information, see ASP.NET Routing.

  • Understanding LINQ-to-SQL Object-Relational mapping. For more information, see LINQ to SQL.

  • Understanding the ADO.NET Entity Framework. For more information, see ADO.NET Entity Framework.

Back to top

See Also


Walkthrough: Creating a New ASP.NET Dynamic Data Web Site Using Scaffolding

Walkthrough: Adding Dynamic Data to an Existing Web Site


ASP.NET Dynamic Data Infrastructure

ASP.NET Dynamic Data Scaffolding and Page Templates Overview

Adding Dynamic Behavior to ASP.NET Data-bound Controls

ASP.NET Dynamic Data Field Templates Overview

ASP.NET Dynamic Data Model Overview

Change History




July 2008

Added topic.

SP1 feature change.