如何在中继器控件中求和 [英] How to sum a column in repeater control
本文介绍了如何在中继器控件中求和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含13行的中继器控件,我希望从这些行中求和(总计)控件中的一列.我如何获得总计,任何人都请为此发布解决方案.
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.
推荐答案
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;
}
这篇关于如何在中继器控件中求和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文