ListView control in ASP.NET
Before ASP.NET 3.5, developers who needed to display a set of records could choose between the GridView, DataList, and Repeater controls. The GridView provides rich data features, but has a very boxy layout; the DataList and Repeater allow for a more flexible layout, but lack the "point and click" data features found in the GridView, DetailsView, and FormView controls. The ListView bridges the gap between layout flexibility and built-in data features. This control provides you with complete control over the markup output sent down to a client – while still providing rich data paging, editing, deleting and insertion semantics.
The ListView control, does not only encase its rendered output with any additional markup, but also responsible for specifying the precise HTML rendered for the ListView control. Here are the ListView’s 11 templates:
- ItemTemplate
- AlternatingItemTemplate
- EmptyItemTemplate
- EditItemTemplate
- GroupSeparatorTemplate
- ItemSeparatorTemplate
- GroupTemplate
- EmptyDataTemplate
- InsertItemTemplate
- LayoutTemplate
- SelectedItemTemplate
The ListView control, new to ASP.NET 3.5, offers the same rich data features found in the GridView, but allows for a much more flexible rendered output. As we saw here, the ListView’s rendered output is based on the markup, databinding expressions, and Web controls added to its LayoutTemplate and ItemTemplate. There are a number of other templates available, as well, and we will explore these along with features like sorting, paging, deleting, editing, and inserting in future installments of this article series.

Leave a Reply