|
-
Aug 17th, 2008, 02:14 PM
#1
Thread Starter
Frenzied Member
[2005] Add Rows to Bound Gridview
how would I add rows to the footer of a gridveiw. Trying to add some subtotals/totals to a gridview that's already been bound.
-
Aug 18th, 2008, 02:51 PM
#2
Re: [2005] Add Rows to Bound Gridview
If AutoGenerateColumns is True you could use the RowDatabound event to capture the totals and then simply display them in the proper cell of the Footer row. Something like
Code:
Partial Class _Default
Inherits System.Web.UI.Page
Private sngAmount As Single
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Select Case e.Row.RowType
Case DataControlRowType.DataRow
sngAmount = sngAmount + CSng(e.Row.Cells(2).Text)
Case DataControlRowType.Footer
e.Row.Cells(2).Text = sngAmount.ToString
End Select
End Sub
End Class
-
Aug 18th, 2008, 04:10 PM
#3
Thread Starter
Frenzied Member
Re: [2005] Add Rows to Bound Gridview
Thanks for the suggestion Bruce, but I was looking to add more than one. It's really not a big deal though as I just added a html table below the grid with the fields that I want to display. Was just thinking there would be a better way.
-
Aug 18th, 2008, 04:15 PM
#4
Re: [2005] Add Rows to Bound Gridview
what about using Template column so you can display add Lable control in that and during RowDataBound event,if DataControlRowType.Footer than find that label control and use underlying Datatable's Compute method to get Sub/Total of particular column.
__________________
Rate the posts that helped you 
-
Aug 18th, 2008, 04:22 PM
#5
Re: [2005] Add Rows to Bound Gridview
Also This will be helpfull
__________________
Rate the posts that helped you 
-
Aug 19th, 2008, 02:19 AM
#6
Re: [2005] Add Rows to Bound Gridview
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|