2015-04-04 66 views
0

解释一下,我有一个带有列的gridview:数量,单位值,总值和累计值。我需要将累积值列 添加以前的值到当前值。例如:gridview中的自动求和列

量unitary_value total_value accumulated_value

10 10.00 100.00 100.00

20 50.00 1,000.00 1,100.00

5 500.00 2,500.00 3,600.00

基本上它是向上。列值(累计值)取上一行的值并加到当前值上。

如果你能帮助你!

感谢您的关注。

回答

0
TextBox txtBox = (TextBox)rptr.Items[i].FindControl("amount"); 
int unitary_value = Convert.ToInt32(abc.unitary_value); 
total += Convert.ToInt32(txtBox.Text) * unitary_value; 
lblTotal.Text = String.Format("{0:#,###,###.##}", (object)total); 

abc引用您在gridview中使用的表格。创建该对象的实例并调用unitary_value的值。

希望这可能会给你一些帮助!

0
for (int i = 0; i < DGV.Rows.Count; i++) 
{ 
    DGV.Rows[i].Cells[3].Value= (Convert.ToInt32(DGV.Rows[i-1].Cells[3].Value)+Convert.ToInt32(DGV.Rows[i].Cells[2].Value)).ToString();  
}