Click here to Skip to main content
15,885,985 members
Articles / Web Development / ASP.NET

GroupingView

Rate me:
Please Sign up or sign in to vote.
4.88/5 (21 votes)
16 Jul 2008CPOL11 min read 110.7K   4.1K   123  
A templated, data-bound ASP.NET 2.0 control that groups data according to a field in the source, with support for aggregations.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace TestGroupingView
{
    public partial class Sample3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void gvMainGroupings_GroupDataBound(object o, UNLV.IAP.WebControls.GroupingViewEventArgs e)
        {
            Label lbl = e.Item.FindControl("lblGroupIndex") as Label;
            if (lbl != null)
                lbl.Text = e.GroupIndex.ToString();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
University of Nevada, Las Vegas
United States United States
With a background in education, music, application development, institutional research, data governance, and business intelligence, I work for the University of Nevada, Las Vegas helping to derive useful information from institutional data. It's an old picture, but one of my favorites.

Comments and Discussions