ASP.NET Dynamic Data Site Fields Rendering
Introduction
Dynamic Data uses Data context objects and metadata model to present the information using templates. This post speaks about how we can control the display of dynamic data. Some times we want to change the default rendering of the templates.
How we can change the Fields Rendering
1. Let us take sample and change the Field Rendering
From the above sample we are going to change the Display format of the Publish Date field.
2. Open the NorthWind.dbml file from the Dynamic Data Web site project, if you view the code behind file which is automatically generated by the Dynamic Data Web Site Project. It looks like in the following figure
3. We are not editing the above class because it is generated from the Database meta model. We are going to create new partial class with name Book in the App_code folder. It looks like in the following figure.
We added the MetadataType attribute to the book class which is of the type BookMetadata class. BookMetadata class defines the DisplayFormat of the publishdate field.
We have used the DisplayFormat attribute which defines the dateformat with nameparameters.
4. Run the project to see the Result in the Dynamic Data Web site
1 Comment so far
Leave a reply
ASP.NET Dynamic Data Site Fields Rendering…
You’ve been kicked (a good thing) - Trackback from DotNetKicks.com…