Click here to Skip to main content
15,910,234 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a repeater control that contain 13 rows, from that rows i want to sum(Total) a column in the control. How can i Get total, Anyone please post solution for this.
Posted
Updated 21-Nov-11 18:21pm
v2

1 solution

C#
string Total="";
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
              if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {      
            //gives the sum in string Total.                 
            Total += Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "column_name"));
            }
 else if (e.Item.ItemType == ListItemType.Footer)
{
 // The following label displays the total
 Label1.Text = TotalCost;
}
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900