hi We know that we can group data by using "Group by" in Database.
Some times we need to do grouping in ASP.Net.
we can group the data in Gridview control and can shows the summary.
Here, I will provide small code for grouping
Dim remid As String = String.Empty ' Dim x As String = String.Empty Dim y As String = String.Empty 'Dim z As String = String.Empty ' Dim w As String = String.Empty Dim i As Integer Protected Sub details_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles details.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then If remid = e.Row.Cells(1).Text Then details.Rows(i).Visible = False 'e.Row.Cells(2).Text = e.Row.Cells(2).Text & "," & x e.Row.Cells(2).Text = e.Row.Cells(2).Text & "," & y ' e.Row.Cells(4).Text = e.Row.Cells(4).Text & "," & z 'e.Row.Cells(5).Text = e.Row.Cells(5).Text & "," & w remid = e.Row.Cells(1).Text ' x = e.Row.Cells(2).Text y = e.Row.Cells(2).Text ' z = e.Row.Cells(4).Text 'w = e.Row.Cells(5).Text i = e.Row.RowIndex Else remid = e.Row.Cells(1).Text 'x = e.Row.Cells(2).Text y = e.Row.Cells(2).Text 'z = e.Row.Cells(4).Text ' w = e.Row.Cells(5).Text i = e.Row.RowIndex
End If End If
End Sub
In the above code grouping is based on 2nd coumn in the gridview i.e, remid.
I think, this will help for who need grouping data in Gridview
|
No responses found. Be the first to respond and make money from revenue sharing program.
|