Sorting Database Data

You can sort the items in a ListView control by adding one or more button controls to ListView that have a CommandName property set to the value Sort and a CommandArgument property set to the name of a property to sort by. For example, the page in Listing 14.5 contains a ListView control that renders an HTML table. You can click the column headers to sort the table by a particular column (see Figure 14.5).

Figure 14.5. Sorting data with the ListView control.

image

Listing 14.5. SortListView.aspx

images

The two LinkButtons used for ...

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.