Skip to main content

Posts

Showing posts from April, 2011

Datatable Grouping in .Net 2.0

This functionality is missing in the GridView control. There are various ways to go about it. I thought I will do it without Ajax or other overheads. The following code takes in a Datatable as input and returns the grouped Datatable as output. Make the output datatable the source of any gridview! The parameters allow multi column grouping and sorting becomes -----------------------------------------------------------------------   Public Shared Function GroupDataTable(ByVal T1 As DataTable, ByVal GroupByColumns As String(), _     Optional ByVal SortOrder As Boolean() = Nothing, _     Optional ByVal SumColumns As String() = Nothing, _     Optional ByVal HeaderCell As Integer = 0 _     ) As DataTable         Dim T2 As New DataTable         Dim sortStr As String = ""         Dim i, j, N, T, m As Integer         Dim dR1 As DataRow         Dim drSum As DataRow         Dim xS As Double         Try             Dim dView As DataVie