Using the GroupTemplate

You can use the ListView control’s GroupTemplate to group multiple items together. Grouping items is useful when you want to display items in multiple columns. For example, you might want to display a photo gallery in which three pictures are displayed per row.

The page in Listing 14.3 displays a set of photographs within a series of HTML <div> tags. A maximum of three photographs display in each <div> tag (see Figure 14.3).

Figure 14.3. Displaying a photo gallery with a ListView control.

image

Listing 14.3. PhotoGallery.aspx

In Listing 14.3, the photographs are represented with a List collection. The List is bound to the ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.