Click here to Skip to main content
14,211,647 members
Click here to Skip to main content


135 bookmarked

Group GridView Data

Rate this:
4.85 (55 votes)
Please Sign up or sign in to vote.
4.85 (55 votes)
22 Aug 2014     CPOL    
A custom GridView control which provides you an additional facility to group the data in gridview along with the facility to customise the Group Header and Group Footer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

// Written by Anurag Gandhi.
// Url:
// Contact me at:

/// <summary>
/// Summary description for GlobalData
/// </summary>
public class GlobalData
    public static class DataSource
        public static string FileName = "_Data\\Result.xls";
        public static string TableName = "Sheet1$";

    /// <summary>
    /// Returns the KeyValuePair List of columns as a dataSource for ddlGroupColumn.//
    /// </summary>
    /// <returns>List&lt;KeyValuePair&lt;string, string&gt;&gt;</returns>
    public static List<KeyValuePair<string, string>> GetGroupColumns()
        List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
        string[] strColumnList = new string[] { "Year", "Branch", "Gender", "College" };

        list.AddRange(strColumnList.Select(x => new KeyValuePair<string, string>(x, x)));
        return list;

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.


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


About the Author

Anurag Gandhi
India India
Anurag Gandhi is a Developer, Consultant, Architect, Blogger, Speaker and a Microsoft Employee. He is passionate about programming.
He is extensively involved in Asp.Net Core, MVC/Web API, Microsoft Azure/Cloud, web application hosting/architecture, Angular, AngularJs, design and development. His languages of choice are C#, Node/Express, JavaScript, Asp .NET MVC, Asp, C, C++. He is familiar with many other programming languages as well. He mostly works with MS Sql Server as the preferred database and has worked with Redis, MySQL, Oracle, MS Access, etc. also.
He is active in programming communities and loves to share the knowledge with others whenever he gets the time for it.
He is also a passionate chess player.
Linked in Profile:
He can be contacted at:

Disclaimer: Any posts, article, content present in this website is my personal opinion based on best of my knowledge and experience. None of the content provided by me should be considered as official communication/opinion or my Employer.

Layout: fixed | fluid

Article Copyright 2010 by Anurag Gandhi
Everything else Copyright © CodeProject, 1999-2019

Server Web01
Version 2.8.190619.2