Updated: July 2008
Displays the content that is defined for the field in templated data-bound controls, using ASP.NET Dynamic Data features.
Assembly: System.Web.DynamicData (in System.Web.DynamicData.dll)
The control is used by templated data-bound controls, such as FormView or ListView, to display a data field that uses ASP.NET Dynamic Data features in a custom page. You can also use a control in a TemplateField field of a GridView or a DetailsView control.
The control provides functionality that is similar to that of the DynamicField field. However, because the control is only used inside templates, it gives you more flexibility in controlling how the data is displayed since you can add other HTML elements around the field. When you use a control, you can take advantage of the following Dynamic Data features:
•Automatically rendering the proper control for a field by using field templates, based on the data type. The field templates can be globally modified for the entire application.
•Providing built-in data validation based on the database schema. You can also add validation types by customizing the data model.
•Customizing data rendering for individual fields by using attributes in the data model or by using the P:System.Web.DynamicData.DynamicField.UIHint property.
To specify the field to display in a control, set the DataField property to the field name. You can apply a custom formatting string to the field value by setting the DataFormatString property. By default, the formatting string is applied to field values only when the data-bound control is in read-only mode. To apply the formatting string to values displayed while the data-bound control is in edit mode, set the ApplyFormatInEditMode property to true. If a field value is a null reference (Nothing in Visual Basic), you can display a custom caption by setting the NullDisplayText property. The control can also automatically convert empty string ("") field values to null values by setting the ConvertEmptyStringToNull property to true.
The control supports different display modes. To specify the mode in which to display the control, set the Mode property. The following table shows the different modes.
You can hide a control in a data-bound control by setting the Visible property to false.
See a run-time code example of this feature: Run.
The following example demonstrates how to use the control in a ListView control to display, insert, delete and edit values from a database table. It is important to notice that in order to make the insert operation to work, the IsDbGenerated property of the rowguid and ModifiedDate columns are set to true.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.