TechBubbles

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

 

Control1

 

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

Control2

 

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.

 Control3

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

control5

1 Comment so far

  1. DotNetKicks.com September 1st, 2008 8:18 am

    ASP.NET Dynamic Data Site Fields Rendering…

    You’ve been kicked (a good thing) - Trackback from DotNetKicks.com…

Leave a reply