Using RowDataBound sounds ok to me. But how do you know which row not to count? With the answer to that, check for each row if it is that row. If it is, don't count it.
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
Diddi10
Member
2 Points
32 Posts
Calculate Gridview Total in Footer except one row
May 15, 2012 01:18 PM|LINK
I would like to calculate each column total in the footer but except one row.. i dont want to add that row in calculating Total.
i did to caluculate Total in GridView1_RowDataBound but its calculating all the values.
can you please help me to find this
barryman9000
Participant
1698 Points
605 Posts
Re: Calculate Gridview Total in Footer except one row
May 15, 2012 11:10 PM|LINK
Post your code.
- George Carlin
basheerkal
Star
10672 Points
2426 Posts
Re: Calculate Gridview Total in Footer except one row
May 16, 2012 03:52 AM|LINK
One methos is to do it in Databound event and get the sum looping through the number of rows you need.
(Talk less..Work more)
ZeeshanAnsar...
Participant
878 Points
264 Posts
Re: Calculate Gridview Total in Footer except one row
May 16, 2012 04:08 AM|LINK
set hiddenfield into gridview templatefield to indicate that row should not be included in total as your requirement
and in rowdatabound event just check that hidden field if matches then exclude it from suming up and go ahead
I hope this helps you.
Please 'Mark as Answer' if this post helps you.
Twinkle1989
Member
295 Points
127 Posts
Re: Calculate Gridview Total in Footer except one row
May 16, 2012 04:55 AM|LINK
hey
Don't use row_databound event for gridviewrow total
for example
price
1500
2400
2600
3100
after binding gridview. then start foreach statement for gridview
and find control which render values u want to be total
decimal amount=0;
foreach(gridviewrow row in gridview1.rows)
{
amount+=convert.todecimal( ((label)row.findcontrol("your label id")).text);
}
((label)gridview1.fotterrow.findcontrol("")).text=amount.tostring();
Twinkle Arora (India)
superguppie
All-Star
48225 Points
8679 Posts
Re: Calculate Gridview Total in Footer except one row
May 16, 2012 03:23 PM|LINK
Using RowDataBound sounds ok to me. But how do you know which row not to count? With the answer to that, check for each row if it is that row. If it is, don't count it.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.