14.1. Formatting Your Controls Using Styles

Chapters 12 and 13 explain how to work with the numerous data-bound ASP.NET 3.5 controls. You learned how to display and edit lists of data with controls like GridView, Repeater, and ListView, as well as how to work with single record controls like DetailsView.

So far, you've relied on the built-in look and feel of the controls, which results in dull and plain-looking HTML. Figure 14-1 shows the GridView that you created in Chapter 12 to manage the genres in the Planet Wrox database.

Figure 14-1. Figure 14-1

This control relies on the default settings of the browser to display text and links, which usually results in purple and blue links with the default font, like Times New Roman. Additionally, the columns in the grid are just as wide as necessary to display the text they contain. It would be a lot easier on the eyes if you could present the GridView as in Figure 14-2 instead.

Figure 14-2. Figure 14-2

The column for the Edit and Delete links is now a little wider, separating it clearly from the actual content in the grid. The Id column has been hidden and the Name column has been made wider as well. The different colors for the header, footer, items, and alternating items make the data in the grid a lot easier to read.

Changing the ...

Get Beginning ASP.NET 3.5: In C# and VB now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.