O'Reilly logo

ASP.NET 4 24-Hour Trainer by Toi B. Wright

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 22A. Dynamic Data Templates in Web Forms

In Lesson 21A you created a fully functional data-driven application by writing only one line of code. The Dynamic Data framework uses templates to provide the default views for data. It uses entity templates, field templates, and page templates. In this lesson I show you how to customize a page template and how to create a new field template.

PAGE TEMPLATES

The Dynamic Data framework uses five page templates. All of the page templates are just regular ASPX pages. They are:

  • Details.aspx — This page displays the data from a single row of the table.

  • Edit.aspx — This page allows you to edit the data from a single row of the table.

  • Insert.aspx — This page allows you to insert a row into the table.

  • List.aspx — This page lists all of the rows in the table using a GridView control.

  • ListDetails.aspx — This page lists all of the rows in the table using a GridView control and allows you to edit and insert rows using a DetailsView control.

CUSTOM PAGE TEMPLATES

If you make a change to any of the pages in the PageTemplates folder, it will have a global effect on your application. Figure 22A-1 shows the default List.aspx page template.

As you can see the GridView that is used on the default List.aspx page template is not formatted to show alternating rows in a different color. This is the code to have alternating rows of a GridView appear yellow:

<AlternatingRowStyle BackColor="#FFFF99" />

Figure 22A.1. FIGURE 22A-1

If I add the preceding markup to the GridView ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required