Click here to Skip to main content
13,198,075 members (64,125 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi friends,
i am stuck in my development,
i have a column named quanity in Gridview and another column name Price per Unit,
Total in which value=quantity*PricePerUnit;
but i have a TextChanged Event for Quantity textbox on which calculation is done and displayed in total Column of Gridview.

now i want the Sum of (Total) Column in GridviewFooter. as i enter the value in Quantity of any row in Gridview.

need help

regards
Aamir
Posted 19-Jul-12 19:40pm
aamir07680
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

This code will help you:-
 int total = 0;
protected void girdview_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
  if(e.Row.RowType == DataControlRowType.DataRow)
  {
    total += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Amount_column"));
   }
  if(e.Row.RowType == DataControlRowType.Footer)
  {
    Label lblAmount = (Label)e.Row.FindControl("amountLabe");
    lblAmount.Text = total.ToString();
  }
}


Good luck.
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

You need to keep the track of total per row in RowDataBound event. At the end, assign the total to the footer template total field.

Have a look here: MSDN: GridView Examples for ASP.NET 2.0: Displaying Summary Data in the Footer[^]

Go through it, learn and try out.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

Dear friends,
i am getting the following error:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'total'.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.171020.1 | Last Updated 20 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100