GeekArticles
Database
SQL ServerUsing ASP.NET 3.5's ListView and DataPager Controls: Grouping Data with the ListView Control
Author: aspnet.4guysfromrolla.com |
Published: 2nd Jan 2008 |
Visited: 79 times |
Add CommentFiled in: SQL Server
ASP.NET version 3.5 added two new data Web controls to the Toolbox: the ListView and DataPager. As discussed in the first installment of this article
series, Displaying Data with the ListView, the ListView control offers the same
built-in features found in the GridView, but much finer control over the rendered output. The ListView's output is defined using a variety of templates,
and we looked at examples using the control's LayoutTemplate and ItemTemplates. In particular, these examples used a LayoutTemplate that included a
placeholder for the ItemTemplate's rendered output.
The ItemTemplate is rendered for each record bound to the ListView control, and is typically referenced in the LayoutTemplate. This approach generates
the rendered markup defined in the LayoutTemplate, plus the rendered markup created by the ItemTemplate for each record. This works fine for simple
rendering scenarios, but in more complex scenarios we may need to render different formatting markup for different groups of records.
For example, imagine that we needed to display a set of records in a three-column HTML <table>. For each record we would want to
emit a table cell (<td>), but for every three records we would need to emit a new table row (<tr>).
Such customizations can be accomplished declaratively with the ListView control's includes GroupTemplate and GroupItemCount properties.
In this article we will see how to use the GroupTemplate and GroupItemCount properties to instruct the ListView control to render
different encasing markup for every n records. We will look at two demos: one that renders records into a series of ordered lists, and
another that illustrates how to display data in a multi-column table. Read on to learn more!
Read More >
Read Article Sponsored Links
Related Articles
• Speeding Up Data Submission The goal of building an Ajax based application is to ensure that interactivity of the site to the user is highly optimized. One of the main features of Ajax is to create an application that should predict what the user actually needs. As the user key in a letter the application will communicate to t ...
• Swing Extreme Testing - The Data Validation Test The Data Validation Test
The Ok button of the SaveAsDialog should only be enabled if the name that has been entered is valid. A name can be invalid if it contains an illegal character, or if it has already been use ...
• Retrieving XML Data Retrieving XML DataTo retrieve XML data from an XMLType table, you can use a SELECT SQL statement, just as you would if you had to query a relational table. For example, to select the employee with the id set to 100 from the employees XMLType table discussed in the preceding section, you might issue ...
• Querying Data with Oracle XQuery Querying Data with Oracle XQuery
Starting with Oracle Database 10g Release 2, you can take advantage of a full-featured native XQuery engine integrated with the database. With Oracle XQuery, you can accomplish various tasks involved in developing PHP/Oracle XML applications, operating on any kind of ...
• Breaking up XML into Relational Data Breaking up XML into Relational Data
While the preceding example shows how to construct an XML representation over relational data, the example in this section illustrates how you can shred XML data back into relational data. This reverse operation can be useful if your application works with relati ...
• Accessing and Updating Data in ASP.NET 2.0: Using Optimistic Concurrency
Because multiple users can visit the same web page concurrently, it is possible for a user visiting a data modification page to inadvertently overwrite
the modifications made by another user. Consider a page with an editable GridView. If two users visit this page simultaneously from different compu ...