如何在标签上的数据网格视图中显示总计。 [英] How to display total in Data Grid View on Label.

查看:142
本文介绍了如何在标签上的数据网格视图中显示总计。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dim Gross As Decimal = 0

Dim i As Integer = 0

If(DataGridView1.Rows.Count> 0)然后

{

For i = 0 To DataGridView1.Rows.Count

{

Gross = Gross + Convert.ToDecimal(((lblAmount)DataGridView1 .Rows [i] .FindControl(lblAmount))。Text.ToString())

}

下一页

}

结束如果



我使用上面的代码显示标签中数据gridview中Amount列的总数。



Gross = Gross + Convert.ToDecimal(((lblAmount) DataGridView1 .Rows [i] .FindControl(lblAmount))。Text.ToString( ))
突出显示的零件系统上的
给出错误'')''预期。我正在使用VB.net。



请给我正确的语法。

Dim Gross As Decimal = 0
Dim i As Integer = 0
If (DataGridView1.Rows.Count > 0) Then
{
For i = 0 To DataGridView1.Rows.Count
{
Gross = Gross + Convert.ToDecimal(((lblAmount)DataGridView1.Rows[i].FindControl("lblAmount")).Text.ToString())
}
Next
}
End If

I used above code for display total of Amount column in data gridview in label.

Gross = Gross + Convert.ToDecimal(((lblAmount)DataGridView1.Rows[i].FindControl("lblAmount")).Text.ToString())
on highlighted part system gives an error '')'' expected.I am using VB.net.

Please give me correct syntax.

推荐答案

Convert.ToDecimal(DirectCast(DataGridView1.Rows(i)。 FindControl(lblAmount),lblAmount).Text.ToString())



我不是100%肯定,但尝试使用上面的stmt。
Convert.ToDecimal(DirectCast(DataGridView1.Rows(i).FindControl("lblAmount"), lblAmount).Text.ToString())

I m not 100% sure but try using above stmt.


这篇关于如何在标签上的数据网格视图中显示总计。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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