PC Review


Reply
Thread Tools Rate Thread

Subtotals in Gridview

 
 
Hutty
Guest
Posts: n/a
 
      22nd Jul 2008
I have searched the net but have been unable to find a solution to
subtotaling in a gridview. I have a gridview that is bounded to sqldatasource
where I would like to subtotal rows throughout the gridview based on column
value "Type". I am using VB.NET. Thanks.
--
Hutty
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      23rd Jul 2008
The way to do this sort of things is to use a repeater or a listview with
ItemTemplate made out of two html table rows. The first <tr> will be used as
a regular row. The second <tr> will contain subtotals. It will be hidden for
all items (rows) but the last item for each Type. You will need to handle
either ItemDataBound or PreRender event to calculate the subtotals, detect
the last item for every Type and show the subtotal <tr> for the detected
last items.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Hutty" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have searched the net but have been unable to find a solution to
> subtotaling in a gridview. I have a gridview that is bounded to
> sqldatasource
> where I would like to subtotal rows throughout the gridview based on
> column
> value "Type". I am using VB.NET. Thanks.
> --
> Hutty



 
Reply With Quote
 
 
 
 
Hutty
Guest
Posts: n/a
 
      23rd Jul 2008
I failed to mention I am using a nested gridview in application. The second
gridview shows the details of the master gridview where I want to display
totals. My goal is to show hierarchial data with subtotals at major
intervals. Will the repeater accomplish this task? Thanks.
--
Hutty


"Eliyahu Goldin" wrote:

> The way to do this sort of things is to use a repeater or a listview with
> ItemTemplate made out of two html table rows. The first <tr> will be used as
> a regular row. The second <tr> will contain subtotals. It will be hidden for
> all items (rows) but the last item for each Type. You will need to handle
> either ItemDataBound or PreRender event to calculate the subtotals, detect
> the last item for every Type and show the subtotal <tr> for the detected
> last items.
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
>
> "Hutty" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have searched the net but have been unable to find a solution to
> > subtotaling in a gridview. I have a gridview that is bounded to
> > sqldatasource
> > where I would like to subtotal rows throughout the gridview based on
> > column
> > value "Type". I am using VB.NET. Thanks.
> > --
> > Hutty

>
>
>

 
Reply With Quote
 
rajiv gandhir
Guest
Posts: n/a
 
      13th Apr 2010
I have searched the net but have been unable to find a solution to
subtotaling in a gridview. I have a gridview that is bounded to sqldatasource
where I would like to subtotal rows throughout the gridview based on column
value "Type".
I am using VB.NET.

Regards
RAJIV



Hutt wrote:

Subtotals in Gridview
22-Jul-08

I have searched the net but have been unable to find a solution to
subtotaling in a gridview. I have a gridview that is bounded to sqldatasource
where I would like to subtotal rows throughout the gridview based on column
value "Type". I am using VB.NET. Thanks
--
Hutty

Previous Posts In This Thread:

On Tuesday, July 22, 2008 1:26 PM
Hutt wrote:

Subtotals in Gridview
I have searched the net but have been unable to find a solution to
subtotaling in a gridview. I have a gridview that is bounded to sqldatasource
where I would like to subtotal rows throughout the gridview based on column
value "Type". I am using VB.NET. Thanks
--
Hutty

On Wednesday, July 23, 2008 9:10 AM
Eliyahu Goldin wrote:

The way to do this sort of things is to use a repeater or a listview with
The way to do this sort of things is to use a repeater or a listview with
ItemTemplate made out of two html table rows. The first <tr> will be used as
a regular row. The second <tr> will contain subtotals. It will be hidden for
all items (rows) but the last item for each Type. You will need to handle
either ItemDataBound or PreRender event to calculate the subtotals, detect
the last item for every Type and show the subtotal <tr> for the detected
last items

--
Eliyahu Goldin
Software Develope
Microsoft MVP [ASP.NET
http://msmvps.com/blogs/egoldi
http://usableasp.ne

"Hutty" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

On Wednesday, July 23, 2008 2:05 PM
Hutt wrote:

I failed to mention I am using a nested gridview in application.
I failed to mention I am using a nested gridview in application. The second
gridview shows the details of the master gridview where I want to display
totals. My goal is to show hierarchial data with subtotals at major
intervals. Will the repeater accomplish this task? Thanks
--
Hutt

"Eliyahu Goldin" wrote:


Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF Reflection Effect
http://www.eggheadcafe.com/tutorials...on-effect.aspx
 
Reply With Quote
 
Gregory A. Beamer
Guest
Posts: n/a
 
      13th Apr 2010


"rajiv gandhir" wrote in message news:(E-Mail Removed)...
> I have searched the net but have been unable to find a solution to
> subtotaling in a gridview. I have a gridview that is bounded to
> sqldatasource
> where I would like to subtotal rows throughout the gridview based on
> column
> value "Type".
> I am using VB.NET.


You have two choices in ASP.NET (actually any .NET)

1. Filter the results prior to binding. This means calculating subtotals and
making them a new field before you bind
2. Intercepting the binding event and adding the subtotals.

Either will work. I prefer the first if it is every row. And you have two
choices on that one:

1. Refactor the query to add subtotal (if per row subtotal is the goal this
works well)
2. Refactor the data object to add subtotal

On the second point, you can add a column to a DataSet (if used) or have the
object with a subtotal field that is automatically calculated by the "domain
model" data object.

If none of this makes sense, you need to google the basics of domain
modeling or DataSets, and possibly the binding events in the Grid you are
using.

--
Peace and Grace,
Greg

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

************************************************
| Think outside the box! |
************************************************

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= Microsoft ASP .NET 1 9th May 2006 07:48 PM
Problem with nested subtotals, placing secondary subtotals BELOW . =?Utf-8?B?RGF3biBDYW1lcm9u?= Microsoft Excel Misc 1 3rd Jun 2005 10:13 PM
When using subtotals, how do I copy and paste only the subtotals . =?Utf-8?B?V2VuZHk=?= Microsoft Excel Worksheet Functions 0 12th Feb 2005 12:05 AM
why are nested subtotals coming out below outer subtotals? =?Utf-8?B?SGVuZHk=?= Microsoft Excel Worksheet Functions 2 18th Jan 2005 09:09 PM
Subtotals - Copy the Subtotals into a new sheet Microsoft Excel Worksheet Functions 2 15th Apr 2004 04:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:16 AM.