473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

totals at the top of a DataGrid?

Is there any way to get FooterText to show at the top of the grid instead of
the bottom? We have hundreds of pages of grids that are almost always too
tall to show on a page. Users are constantly scrolling down to the bottom
to see the totals as soon as the page shows. I know I can crunch this out
in code by putting a table on top of the grid and writing code to put the
totals in the table but...

Is there an easy way?
Thanks,
G
Nov 18 '05 #1
4 1291
Sure, but you would need a trick.
Enable showing the Pager if you are not using it (AllowPaging = true). Set
the property PagerStyle.Position to Top (or TopAndBottom if you need the
real pager).
Now you'll use the ItemCreated event to check if the item being creaeted is
a Pager row (verify e.Item.ItemType ), if it is the pager, then remove the
exisiting cells on the item and create the cells that will show the totals,
programatically.

It's not one of the easiest things to be done but definately feasible.

--
TJoker
MVP: Paint, Notepad, Solitaire

****************************************

"Gary" <gb@nospam.com> wrote in message
news:e9****************@TK2MSFTNGP09.phx.gbl...
Is there any way to get FooterText to show at the top of the grid instead of the bottom? We have hundreds of pages of grids that are almost always too
tall to show on a page. Users are constantly scrolling down to the bottom
to see the totals as soon as the page shows. I know I can crunch this out
in code by putting a table on top of the grid and writing code to put the
totals in the table but...

Is there an easy way?
Thanks,
G

Nov 18 '05 #2
Hi Gary,

Thanks for posting in the group.

As I understand, the question is: Is there any way to add a customized row
in the top of the datagrid to work like a summary row, right?

Generally speaking, if we want to add a summary row in the end of the
datagrid, we could use its ItemDataBound and change the content of its
ListItemType.Footer. However, if we want to add it to the begining of the
datagrid, that may need some coding.

TJoker has provided you an method on it. :) You could try it first. I am
not sure of your method of putting a table on top of the grid since you
haven't introduced it much. Based on my experience, we can response to
datagrid's PreRender to add a new row into it as the following: (is it the
same as yours?)

Private Sub DataGrid1_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DataGrid1.PreRender

Dim dgitem As New DataGridItem(0, 0, ListItemType.Header)
Dim mycell As New TableCell()
mycell.ColumnSpan = 2 'Set it to the colspan that you want
mycell.Text = "This is the top level header item spanning two columns!"
dgitem.Cells.Add(mycell)
DataGrid1.Controls(0).Controls.AddAt(0, dgitem)

End Sub

Hope that helps.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 18 '05 #3
Thanks. I'll poke around with this idea. I think that creating a derived
datagrid control might be the best approach.
Gary

"Yan-Hong Huang[MSFT]" <yh*****@online.microsoft.com> wrote in message
news:iF****************@cpmsftngxa06.phx.gbl...
Hi Gary,

Thanks for posting in the group.

As I understand, the question is: Is there any way to add a customized row
in the top of the datagrid to work like a summary row, right?

Generally speaking, if we want to add a summary row in the end of the
datagrid, we could use its ItemDataBound and change the content of its
ListItemType.Footer. However, if we want to add it to the begining of the
datagrid, that may need some coding.

TJoker has provided you an method on it. :) You could try it first. I am
not sure of your method of putting a table on top of the grid since you
haven't introduced it much. Based on my experience, we can response to
datagrid's PreRender to add a new row into it as the following: (is it the
same as yours?)

Private Sub DataGrid1_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DataGrid1.PreRender

Dim dgitem As New DataGridItem(0, 0, ListItemType.Header)
Dim mycell As New TableCell()
mycell.ColumnSpan = 2 'Set it to the colspan that you want
mycell.Text = "This is the top level header item spanning two columns!"
dgitem.Cells.Add(mycell)
DataGrid1.Controls(0).Controls.AddAt(0, dgitem)

End Sub

Hope that helps.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 18 '05 #4
Hi Gary,

You are welcome. :) Creating a customized control is a good idea if the
control is supposed to be reused.

Thanks for participating the community. Have a good day.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: | last post by:
I have gotten the following error in trying to get totals to come out on a footer. Server Error in '/test' Application....
3
by: mark | last post by:
im keeping running totals of certain columns in a datagrid, id like to put these totals in the footer - how do i do this ? or how can i put a label into the footer ? (im displaying results using...
2
by: Greg | last post by:
I was wondering if there is a simple way to present a totals column in a bound datagrid where the totals aren't actually persisted (in my case to an xml file). Ideally, when I populate the datagrid...
2
lee123
by: lee123 | last post by:
is there a way to add up all the totals in a datagrid to make one total in a form ( not in the datagrid outside of the grid). like in a textbox. lee123
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.