Click here to Skip to main content
12,549,311 members (47,412 online)
Click here to Skip to main content
Add your own
alternative version


26 bookmarked

Grouping Rows in a DataGrid

, 26 Apr 2005
Rate this:
Please Sign up or sign in to vote.
Grouping Rows in a DataGrid using C# and ASP.NET.


This is built off the same idea that Serge Lobko-Lobanovsky had in his article on here at

had trouble with the code he had posted and had to get it done for a project. Just call the method DataGridGroupBy(DataGrid dgYouWantGrouped, int ColumnToGroup) of the DataGridGroupByRows class in your WebForm and it will group all rows you want grouped together.

Here is the code for a class i wrote in the sample project attached:

using System;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace localhost
/// <span class="code-SummaryComment"><SUMMARY>


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
Web Programmer / Analyst for, and part owner

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
Hristo Bojilov27-Aug-09 4:53
memberHristo Bojilov27-Aug-09 4:53 
GeneralLast row in datagrid does not group [modified] Pin
John hazin10-Dec-07 4:58
sussJohn hazin10-Dec-07 4:58 
GeneralRe:Grouping Rows in a DataGrid Pin
Volcano__12-May-07 6:46
memberVolcano__12-May-07 6:46 
GeneralFixed and understandible Pin
mgrisoli8-Jan-07 6:18
membermgrisoli8-Jan-07 6:18 
GeneralLast Row Problem solved .. [modified] Pin
VMSSanthosh20-Sep-06 19:39
memberVMSSanthosh20-Sep-06 19:39 
GeneralThank you! Pin
Shivam Ray16-Aug-06 13:42
memberShivam Ray16-Aug-06 13:42 
GeneralMy implementation with stylesheet support Pin
koedoot15-Mar-06 0:04
memberkoedoot15-Mar-06 0:04 
QuestionWhat&#180;s going on with the las row? Pin
Francisko20-Jul-05 9:24
memberFrancisko20-Jul-05 9:24 
AnswerRe: What&amp;#180;s going on with the las row? Pin
Spithas2-Nov-05 22:39
memberSpithas2-Nov-05 22:39 
AnswerRe: What's going on with the last row? Pin
RoyPardee5-Jul-06 11:22
memberRoyPardee5-Jul-06 11:22 
GeneralRe: What's going on with the last row? Pin
mgrisoli8-Jan-07 6:16
membermgrisoli8-Jan-07 6:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161021.1 | Last Updated 26 Apr 2005
Article Copyright 2004 by BriOnH
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid