.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Gridview Totals in Footer

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :ASP.Net
 I am having problems with displaying the totals in the footer of a gridview. I am writing a page whereby users can enter comments and marks for an online photo competition. The page has a details view to enter the comment and mark. Its has a details view where the photo is displayed. It has a gridview where the comments and marks that have been entered are displayed. It works well - the details view allows comment and mark entry and the gridview show the comments and marks as they are entered. The problems are twofold. Firstly the total shows double the marks that should be displayed. Secondly, when you leave the page and then return later, you have to refresh the page before it will show the latest comment and mark even though it shows this immediately after entering the data. Ive provided my code below:   Partial Class PhotoAlbum_PhotoDetails     Inherits System.Web.UI.Page     Private TotalMarks As Decimal     Protected Sub DisplayComment_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles DisplayComment.RowDataBound         If e.Row.RowType = DataControlRowType.DataRow Then             TotalMarks += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Mark"))   

View Complete Post

More Related Resource Links

sum of 7 column totals in footer of gridview

I have implemented column tolals in the footer of my gridview using the technicque described in this article http://aspalliance.com/782 .Now I would like to have a total of the 7 column totals that are displayed in the footer.  Can anyone tell me how to do this.  I would like to display this in a label or an addition row in the footer if that is possible.

How to Fixed GridViews Header and Footer when scrolling in asp.net?

This article is to show you how to Fix GridView''s Header and Footer in a simple code with CSS and JavaScript

Show grand total running total in GridView Footer

In many scenarios we need to display Running total as well as Grand total in GridView footer. In this post i will try to explain in an easy way that how we can display running total & Grand total in a GridView footer combindly. To explain this solution using an example here i use a sales order report. The report contains all sales order amount in a tabular way. I will use a GridView to display sales order amount and use GridView footer to display Running total & Grand total. Let we have a customer table with id and name column plus an orders table with OrderID,CustomerID,OrderDate & Amount. Now our goal is to show all customers order with amount as well as page wise running total & grand total. Note that running total is necessary when you enable paging in a GridView where as Grand total is always you can consider.

inserting from gridview footer


I have been following the tutorials from Scott Mitchell on this site.  I am trying to insert a new record from the gridview footer.  I have my BLL set up as a .cs class in the App Code folder.  When I fill in the fields and click add, nothing happens.  The page refreshes and the text boxes empty, but nothing is added to the database.  The edit and delete functions work fine.  Have I put something in the wrong spot?


I have the rowcommand and the datasource_inserting on the code page as below.

protected void Oems_RowCommand(object sender, GridViewCommandEventArgs e)
    // Insert data if the CommandName == "Insert" 
    // and the validation controls indicate valid data...
    if (e.CommandName == "Insert" && Page.IsValid)
        // TODO: Insert new record...

protected void OemsDataSource1_Inserting
(object sender, ObjectDataSourceMethodEventArgs e)
    // Programmatically reference Web controls in the inserting interface...
    TextBox txtOem = (TextBox)GridView1.FooterRow.FindControl("txtOem");
    TextBox txtOemStreet = (TextBox)GridView1.FooterRow.FindControl("txtOemStreet");
    TextBox txtOemCity = (TextBox)GridView1.FooterRow.FindControl("txtOemCity");

SSRS 2008 group footer totals on a new page has a non-expected large cell height

SSRS 2008 group footer totals on a new page has a non-expected large cell height. When the group total is the first component on a new page, then this happens, but when it is part of the group on but not the first component, then it reverts to normal cell height. I have played with the advance settings now for hours, but cannot get this to work. Any ideas?  

Footer and Header in Empty GridView

How to make GridView to show Header and Footer when it hasn't got any rows?

Is possible...? set enter key button for gridview footer template..

http://geekswithblogs.net/dotNETvinz/archive/2009/06/04/adding-dynamic-rows-in-gridview-with-textboxes.aspxI have used the above grid view in my application . Its working good, no problem. Upon clicking the Addnewrowbutton, it uses to create a new row dynamically. What i need is, new row should also be created dynamically, upon pressing enter key in the last textbox on a particular gird view row.  User always can't go and click addnewrowbutton every time to create new row. Instead of it, user can press enter in the last textbox on a particular grid view row to create new row. Hope you guys have understood. Please Note: Here I have used master page.

Display selected items total in gridview footer


Hi all,

           I will have a gridview with checkboxes and some amount fields. I would like to display the sum of the amount in gridview footer depending on the checked items by the user. Can any one give me a sample code

Can not reference text value in footer of Gridview control


I have been struggling with this all week end .... Yell

I am trying to implement adding a new record using the Gridview footer.

I have an example that works finethat I got from http://www.aspdotnetcodes.com/GridView_Insert_Edit_Update_Delete.aspx.

My situation is a little different .. as I am using master page and the Gridview is in a page derived from the master page.

I have tried:

Dim txtNewName As TextBox = DirectCast(GridView1.FooterRow.FindControl("NewName"), TextBox)

"NewName" is the ID of the textbox in the footer of the Gridview.

When I try referencing ... txtNewName.Text ... it returns a null value.

There must be some trick to referencing this .Text value when using the Gridview that is within a Content Place Holder that results when using a page that was created using a master page.


Thanks in advance fo any possible help with this problem ...

Gridview Subtotals and totals


my table has div code, inventory date, landfill name , no of tonnes and total tonnes for a particular division and month tht the user selects

i need to display data such as show below as a sample:-

Division Month   day Landfill Name No Of Loads Total tonnes
000        August  1     Niagara            10                   5
000        August  2     Niagara            10                   5
000        August  3     Niagara            10                   5
000        August  4     Niagara            10       &nb

GridView Insert clicking a button in footer row using stored procedure


Hi!! I need your help again.

I have a gridview with a button in the first column of the footer row and some controls (textbox, dropdowlist...) in the rest of the columns. I want to click that button and insert into a database table using an stored procedure the text properties of the controls in the other columns.

I don't know what's wrong... could you help me or post me a link to read it??

I'm setting the insert command with my stored procedure, I'm setting the storedprocedure as the insertcommandtype, I'm able to load the controls with correct values, but finally when I click the insert button that's not work!!!!

Thank you!!!

perform sum of textbox values and display the total in gridview footer row textbox


i have a gridview in which i have added two textboxes .

the second textbox is placed in footer of gridview

wht i want is when the user enters values in the first textbox the total of these textboxes should be displayed in footer row.

Pls help

Update panel problem in gridview footer


On my aspx page, I'm having troubles when I have an update panel within the footer template of a gridview. It appears to be an intermitent problem that occurs on subsequent postback when you do a delete command in the gridview. The first delete command always goes through fine (first postback). Clicking on another row to delete on the gridview (or any other button on the form) triggers this error:

An error has occurred because a control with id 'ctl00$SupremeContent$grdLineNumbers$ctl09$ctl00' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error.

If you click the back button in the browser, then click on another page, then come back to this page, you can delete another record. Another attempt to delete another record brings you back to the above problem. Thectl00$SupremeContent$grdLineNumbers$ctl09$ctl00 changes each time you delete, come back to the page and delete.

If I disable the udpate panel, there's no errors.

The reason I have the update panel is so that the user can select the relevant pipe specification (they see multiple columns using a textbox, drop down extender, panel and gridview) without the form's data being reset by the embedded gridview's

How to compare asp.net Textbox value is equal to Gridview footer itemtemplate text box on button cli



I have one asp.net textbox and gridview footer template textbox on clicking the button, i need to check the textbox value is equal to gridview footer template textbox value are same....

my aspx page code:-

     <asp:TextBox ID="TextBox3" runat="server" TabIndex="1"></asp:TextBox>

<asp:TextBox id="we" runat="server"  Font-Size="10pt" Font-Names="Palatino Linotype" Font-Bold="True" ForeColor="#000000" Width="106px">

  <asp:Button ID="Button2" runat="server" BackColor="Transparent" BorderColor="Transparent"                      
                        Font-Size="10pt" ForeColor="#FFFFFF" Height="40px" OnClick="Button2_Click" Style="z-index: 101;
                        left: 113px; background-image: url(images/btn_5.png); position: absolute; top: 13px;
                        background-color: transparent" Text="Save" Width="94px" />

How to Leave footer visible in gridview when datasource is empty



I want to display my <FooterTemplate> or just the textbox and button when the gridview is empty. Here is the code I have that works fine when my datasource is not null but when it is null I want to show the <FooterTemplate> I have. 

Btw my project is VB.Net.  Oh yeah <emptydatatemplate> did not work for me.  I copied the below in between the <emptydatatemplate> and it did not work.  So I removed the template tags inside <emptydatatemplate> and still did not work. Any suggestions?

<asp:GridView ID="mlbGridView" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="mlbDataSource" ShowFooter="True"  OnRowCommand="mlbGridView_RowCommand">

    <asp:Button ID="btnInsert" runat="se

Round Gridview footer template textbox value based on this JavaScript



This is my aspx javascript to get total in gridview footer template.. its working fine

The problem is : some time it show footer value is 6.9999999999

I need 6.99 as a result how to achieve this.

Aspx page:-

<script type="text/JavaScript">
function updateControls(elementId)
 var parentElementRef = document.getElementById(elementId);
 var elementRefArray = parentElementRef.getElementsByTagName('INPUT');
 var textBoxTotals = 0;

 for (var i=0; i<elementRefArray.length; i++)
  var elementRef = elementRefArray[i];

  if ( (elementRef.type == 'text') && (elementRef.gridTextBoxType == 'calcTextBox') )
   var textBoxAmount = parseFloat(elementRef.value);
   if ( isNaN(textBoxAmount) == true )
    textBoxAmount = 0;

   textBoxTotals += textBoxAmount;

 if ( isNaN(textBoxTotals) == true ) 
  textBoxTotals = 0;

 for (var i=0; i<elementRefArray.length; i++)
  var elementRef = elementRefArray[i];

  if ( (elementRef.type == 'text') && (elementRef.gridTextBoxType == 'totalsTextBox') )
   elementRef.value = textBoxTotals;
// -->


protected void Gridview1_RowDataBound(object sender, Grid

Fixed footer in gridview using jquery


 Hi This is vijay. I want Fixed footer in gridview using jquery.

I found the article like Fixed header in Gridview in the following link.. http://www.dotnetcurry.com/ShowArticle.aspx?ID=255&AspxAutoDetectCookieSupport=1.

In the same jquery can I make fixed footer?. or any other code fixed footer in gridview. Please help me.


Thanks & regards

Vijay kumar

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend