C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Grouping using Gridview


Posted Date: 23 Aug 2008    Resource Type: Articles    Category: .NET Framework

Posted By: Rajendar Reddy       Member Level: Bronze
Rating:     Points: 10



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




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Grouping  .  Gridview  .  ASP.NET  .  .Net  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Using Statement in C#
Previous Resource: System.IO.Path
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

budget conference call

Contact Us    Privacy Policy    Terms Of Use