How To: Customize Dynamic Data Fields
Introduction
This topic demonstrates how to customize built-in dynamic data fields. ASP.NET Dynamic Data generates a set of dynamic data fields that are derived from the base FieldTemplateUserControlBase class. The dynamic data fields are user controls that render database data. ASP.NET Dynamic Data determines which control to render by examining the data field type. For example, if the data field type is an integer, the Dynamic Data framework renders Integer.ascx for display and Integer_Edit.ascx for editing.
The following example uses a customized version of the built-in DateEdit_Edit.ascx user control. When you run the example, if you click the Edit link in the displayed table, the page shows data fields by using a blue background and a red foreground.
Note
The customization described here applies to the whole Web application. This means that it affects the rendering of the editing field of datetime data types in every table.
For information about how to create a data-driven Web site, see Walkthrough: Building a Data-Driven Web Site Using ASP.NET Dynamic Data.
To run the example code in this topic, you will need the following:
To customize a built-in dynamic data field
-
In Solution Explorer, open the App_Shared/DynamicDataFields folder.
-
Open the .ascx file for the dynamic data field that you want to customize.
For example, to customize the dynamic data field that is used to let users edit datetime data, open the DateTime_Edit.ascx user control.
-
Modify the existing markup to change the rendering.
The following example shows the markup for the control with the BackColor and ForeColor properties changed.
<asp:TextBox ID="TextBox1" runat="server"
BackColor="Yellow"ForeColor="Red"Text='<%# DataValue %>'> </asp:TextBox>
Conclusion
This topic is ASP.NET Extensions documentation and is unsupported by Microsoft. Blank topics are included as placeholders and existing content is subject to change in future releases.