Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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
aamir07655
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  
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  

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

  Print Answers RSS
0 Nirav Prabtani 298
1 OriginalGriff 289
2 Sergey Alexandrovich Kryukov 225
3 _Amy 165
4 Richard MacCutchan 135
0 OriginalGriff 7,799
1 Sergey Alexandrovich Kryukov 6,966
2 Maciej Los 3,994
3 Peter Leow 3,708
4 CHill60 2,742


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 20 Jul 2012
Copyright © CodeProject, 1999-2014
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