Asp.net dynamic data field templates overview


















How to: Use ASP. Describes how to work with templated data-bound controls and use the DynamicControl to take full advantage of customization and Dynamic Data capabilities. Shows how to use the UIHint property to specify what field template to use when a column is rendered.

Provides an introduction to the data model, which shows the role of metadata and the relationship between the model and the data fields that are rendered by using field templates. Shows how to customize the appearance and behavior of data fields in the data model that are not part of the database schema. NET Entity Framework. Skip to main content.

This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Make your code more reusable by creating data-related logic in the data layer instead of embedding it in the presentation layer.

The models provide an easy way to integrate data validation and business logic rules into the data model. Dynamic Data scaffolding can support only one of the data model types in the same project. At run time, Dynamic Data automatically extracts information about the data model, such as data field properties. From this information, it infers how to create UI for displaying and editing data.

To render the UI, it uses field templates. For example, Dynamic Data uses the following information to render UI:. Information about associations between tables is used to display foreign-key columns and navigate between tables. Data-type information is used to add validation for a data field. For example, null column information can be used to determine whether a data field is required, and length information can be used to restrict the maximum length of user's text input.

Dynamic Data uses the data-model metadata to automatically determine which field templates to use to render the UI for displaying and modifying data fields. Field templates are user controls that Dynamic Data provides to display and modify the data fields based on their intrinsic data types. To render a data type, Dynamic Data performs a search through the data model, looking for classes that have the UIHintAttribute attribute applied. If the attribute exists, it specifies which field template to use to display and modify a particular data-field type.

If no attribute exists, Dynamic Data searches for a field template whose name matches the data field type. For example, to display an integer value, Dynamic Data searches for a field template named Integer. For more information, see ASP. Dynamic Data lets you customize and extend the UI that is rendered for data field display and editing. You can apply the following customizations:. Add custom metadata to data fields. You can use attributes to assign metadata to data fields to customize how the UI for that data field is rendered for display and editing.

For example, you can use the UIHintAttribute attribute to associate a custom field template with a data field. Add non-intrinsic type information to data-field types. You can use attributes to assign a type to a data field that is not derived directly from the data source.

For example, you can use the DataTypeAttribute attribute to associate an additional, non-intrinsic type with a data field.

Attributes are descriptive declarations that are used to annotate programming elements such as types, fields, methods, and properties. Automatic support for foreign-key relationships. Dynamic Data detects relationships between tables and creates UI that makes it easy for users to view data from related tables.

The ability to customize the UI that is rendered to display and edit specific data fields. The ability to customize the UI that is rendered to display and edit data fields for a specific table. The ability to customize data field validation. This lets you keep business logic in the data layer without involving the presentation layer.

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:. Customizing the UI that is rendered in order to display and edit specific data fields or a specific table.

The data model represents the information that is in a database and how the items in the database are related to each other. 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. 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:. Dynamic Data scaffolding uses page templates to provide a default view of data tables. Page templates are ASP. 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. Dynamic Data uses field templates to render the UI for displaying and editing individual data fields.



0コメント

  • 1000 / 1000