Fares Ayyad

Fares Ayyad

  • NA
  • 235
  • 74.6k

Get the sum of data table column in repeater Footer

Dec 11 2016 4:32 AM

Hello

i'm trying to get the sum of column [Exit Units] in a repeater

with dataTable as datasource, i used to do like that in Page_Load:

  1. if (!IsPostBack)  
  2.     {  
  3.         DataTable dt = (DataTable)Session["CheckedRows"];  
  4.         Repeater1.DataSource = dt;  
  5.         Repeater1.DataBind();  
  6.         foreach (RepeaterItem item in Repeater1.Items)  
  7.         {  
  8.             if (item.ItemType == ListItemType.Item ||item.ItemType == ListItemType.Footer)  
  9.             {  
  10.                 Label lblExitSum = (Label)item.FindControl("lblExitCount");  
  11.                 string sum = dt.Compute("sum(ExitUni)"string.Empty).ToString();  
  12.                 lblExitSum.Text = sum;  
  13.             }  
  14.         }  
  15.     }  
 but the output is strange and doesn't appeare in the footer after the last row like this:
 
 
Item NoGoods DescriptionUOMExit UnitsUnits New BalanceWT BalanceExit WTExit Amount(LC)
S440862340AC RAMP AW165 PAINT-S440862340A????11.0000000.3650000.182500146.797040
2
F1SEMIAUTO0441C.TO F1-L-16-M 220/240 50HZ MF C.CONT-F1SEMIAUTO0441????11.0000001.1600000.5800001772.856560
 
 
 
the total of the column is 2 but it appears after the first row  

Answers (2)