Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Saturday, September 02, 2006

Including Subheadings in a Datagrid

A short while ago I was tasked with adding subheadings into a datagrid, something I have not tried to do, or even thought of doing prior to this assignment. Thus, the task was a little bit beyond my skillset. Having searched around the net for examples, I came up dry. I eventually solved this problem, so I thought I'd share with you how I accomplished adding subheadings to a DataGrid.

First, let me define what I mean by subheadings. Oftentimes, the data displayed in a DataGrid can be logically grouped in some manner. For example, in Scott Mitchell's An Extensive Examination of the DataGrid Web Control, Scott displays the FAQs from the database. Each of these FAQs belongs to precisely one FAQ category. In the Northwinds database's Products table, each product belongs to precisely one product category. In both of these examples, we can improve the DataGrid UI by showing how these FAQs or products are grouped by category. To illustrate this concept, see the screenshot below, which displays the products from the Northwinds database:

In this article we will examine how to build a DataGrid that provides this user interface. This article assumes you are familiar with DataGrids, databinding, and the DataGrid's ItemDataBound event. If this is not the case, consider reading An Extensive Examination of the DataGrid Web Control and/or the DataGrid FAQs at Continue Including Subheadings in a Datagrid

Post a Comment