473,661 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

add new row to gridview with totals

On my gridview I need to a add a new row that will have totals of a previous
rows. It will be something like this
row1 1 2 3 4 9 10
11
row2 5 6 7 8 12 13
14
Total Row cell[1] + cell[6] | cell[2] + cell[7] | cell[3] + cell[8]
row4 15 16 17 18 19 20
21
and so one, Is this possible to accomplish and if so how would one do
something like this?
Feb 21 '08 #1
3 2777
If you are with VS2008, use new ListView control that lets you use an item
template. Make an item template out of 2 rows, one for the cells and another
for the totals. In the ItemDataBound event calculate the totals and control
the total row visibility.

If you are with VS2005 or 2003, use a repeater.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mike" <Mi**@aseagullp oopedonmyhead.c omwrote in message
news:uD******** ******@TK2MSFTN GP03.phx.gbl...
On my gridview I need to a add a new row that will have totals of a
previous rows. It will be something like this
row1 1 2 3 4 9 10
11
row2 5 6 7 8 12 13
14
Total Row cell[1] + cell[6] | cell[2] + cell[7] | cell[3] +
cell[8]
row4 15 16 17 18 19 20
21
and so one, Is this possible to accomplish and if so how would one do
something like this?


Feb 21 '08 #2
I'm using 2005 and I have the app completed. The users decided to show a
calculation field after the fact.
There is no way in the gridview to get the cell values, calculate them, then
add a new row with that total?
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
If you are with VS2008, use new ListView control that lets you use an item
template. Make an item template out of 2 rows, one for the cells and
another for the totals. In the ItemDataBound event calculate the totals
and control the total row visibility.

If you are with VS2005 or 2003, use a repeater.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mike" <Mi**@aseagullp oopedonmyhead.c omwrote in message
news:uD******** ******@TK2MSFTN GP03.phx.gbl...
>On my gridview I need to a add a new row that will have totals of a
previous rows. It will be something like this
row1 1 2 3 4 9 10
11
row2 5 6 7 8 12 13
14
Total Row cell[1] + cell[6] | cell[2] + cell[7] | cell[3] +
cell[8]
row4 15 16 17 18 19 20
21
and so one, Is this possible to accomplish and if so how would one do
something like this?



Feb 21 '08 #3
"Mike" <Mi**@aseagullp oopedonmyhead.c omwrote in message
news:ue******** *****@TK2MSFTNG P06.phx.gbl...
There is no way in the gridview to get the cell values, calculate them,
then add a new row with that total?
Fairly trivial:
http://www.google.co.uk/search?sourc...iew+totals+row
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Feb 21 '08 #4

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

Similar topics

1
2037
by: NewTel | last post by:
Using this code only gives me one new row. I need a second for some other calculations. How? Protected Sub grdExcel_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then ' add the UnitPrice and QuantityTotal to the running total variables
1
4741
by: NewTel | last post by:
Hi This code works great but it only adds the one row. I need a second one. How? Thanks! Protected Sub grdExcel_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
0
1560
by: placebo137 | last post by:
Hi I have a sql query that Groups the data like so: YEAR WHS Here's the query SELECT TOP 100 PERCENT YEAR() AS Year, , SUM() AS Sales FROM dbo. GROUP BY YEAR(),
1
7005
by: tfsmag | last post by:
Hello, I have a function that returns a dynamically created gridview. This works fine, however it does not seem to be able to maintain state when adding sorting or paging to the gridview. Does anyone have any idea how to get this to work? below is the code. Please bear in mind that the function is actually located in a seperate class file from the page that actually returns the grid. ---code for function that returns the grid, this is...
0
1441
by: tfsmag | last post by:
I know how to do summary footers in a gridview... but when i try it in a paged gridview it puts a footer on every page of just the items on that page. Any suggestions on how to get it to work so that it only posts on the last page of the gridview with the totals for the entire dataset? here is how i'm getting the footer summary now Protected Sub TotIncurGrid_RowDataBound(ByVal sender As Object, ByVal e As...
0
1034
by: John | last post by:
I have a gridview where I need to add totals for each grouped data, example my grid looks like this Sales 2006: BMW 100 Lexus 75 Mercedes 70 Total Sales: 245
3
2809
by: =?Utf-8?B?Um9iZXJ0IENoYXBtYW4=?= | last post by:
Hi, Fairly easy to create one running total for a gridview but what if you have dozens of them? I have a gridview that allows bulk editing (all rows at once) and have it set up so that, on data binding, totals are created for all of the dozens of columns. However I need to have it so that any time someone changes a number in one of the textboxes the totals recalculate (columns need to add up to 100% so the totals act as a guide to...
1
1662
by: Michael | last post by:
I reviewed a couple of tutorials that show how to display totals in the footer of a gridview. My footer shows up blank. Can someone help me. The code is as follows: <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server">
2
3804
by: =?Utf-8?B?SHV0dHk=?= | last post by:
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
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8855
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6185
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.