Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > totals at the top of a DataGrid?

Reply
Thread Tools

totals at the top of a DataGrid?

 
 
Gary
Guest
Posts: n/a
 
      02-22-2004
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


 
Reply With Quote
 
 
 
 
TJoker .NET
Guest
Posts: n/a
 
      02-22-2004
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" <(E-Mail Removed)> wrote in message
news:e99rB4N%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Yan-Hong Huang[MSFT]
Guest
Posts: n/a
 
      02-23-2004
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.

 
Reply With Quote
 
Gary
Guest
Posts: n/a
 
      02-23-2004
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]" <(E-Mail Removed)> wrote in message
news:iFqt5Td%(E-Mail Removed)...
> 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.
>



 
Reply With Quote
 
Yan-Hong Huang[MSFT]
Guest
Posts: n/a
 
      02-24-2004
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running totals in gridview (when you have many totals required) =?Utf-8?B?Um9iZXJ0IENoYXBtYW4=?= ASP .Net 3 02-16-2007 12:03 PM
Showing datagrid totals in the footer =?Utf-8?B?SnVzdGlu?= ASP .Net 9 10-15-2004 09:55 PM
footer totals mark ASP .Net 3 09-07-2004 03:21 PM
Error trying to get totals in footer ASP .Net 2 07-02-2004 05:42 PM
totals at the TOP? Gary ASP .Net Datagrid Control 1 02-22-2004 06:54 AM



Advertisments