如何在for循环中对列值求和? [英] how do I sum column values in for loop?

查看:120
本文介绍了如何在for循环中对列值求和?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何获取extlabel文本并将其一起添加到下一行,最后我会有一个值?



extlabel在模板字段中



例如:

总栏目

$ 200.00

$ 225.00

$ 100.00

$ 700.00





  Dim  p 作为 字符串 = 字符串 .Empty 
对于 每个作为 GridViewRow GridView1.Rows
Dim quantlabel As Label = DirectCast (row.FindControl( < span class =code-string> quantlabel),Label)
Dim extlabel As Label = DirectCast (row.FindControl( extlabel),Label)

如果 quantlabel.text> 0 然后
p + extlabel.text
否则

结束 如果

下一步

解决方案

200.00

225.00


100.00


how would I take extlabel text and add it together to the next row and at the end I would have one value?

extlabel is in template field

example:
total column
$200.00
$225.00
$100.00
$700.00


Dim p As String = String.Empty
        For Each row As GridViewRow In GridView1.Rows
            Dim quantlabel As Label = DirectCast(row.FindControl("quantlabel"), Label)
            Dim extlabel As Label = DirectCast(row.FindControl("extlabel"), Label)
            
            If quantlabel.text > 0 Then
                p + extlabel.text
            Else

            End If

        Next

解决方案

200.00


225.00


100.00


这篇关于如何在for循环中对列值求和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆