为什么它不起作用...我想在页脚中显示行的总和 [英] Why it dosn't work ... I want to display sum of rows in footer

查看:95
本文介绍了为什么它不起作用...我想在页脚中显示行的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在gridview中显示页脚中的工资总额...

仅显示第一行的总和,而(0)不是实际工资

plz帮我找到列薪中所有单元格的总和



我尝试过:



作为整数的点心

对于i = 0到dt.Rows.Count - 1

sum = sum + dt.Rows(i)(Salary )

下一页

GridView1.FooterRow.Cells(3).Text = sum

display the total of salary in in footer in gridview ...
the sum just display for the first row and as (0) not the real salary
plz help me to find sum for all cells in column salary

What I have tried:

Dim sum As Integer
For i = 0 To dt.Rows.Count - 1
sum = sum + dt.Rows(i)("Salary")
Next
GridView1.FooterRow.Cells(3).Text = sum

推荐答案

dt。行(i)(薪水)是DataGridViewCell类型。我很惊讶您的代码没有抛出InvalidCastException。试试这个:



dt.Rows(i)("Salary") is of type DataGridViewCell. I'm surprised your code didn't throw an InvalidCastException. Try this:

Dim sum As Integer = 0
For Each dr As DataGridViewRow In GridView1.Rows
  sum = sum + dr.Cells("Salary").Value
Next
GridView1.FooterRow.Cells(3).Value = sum


这篇关于为什么它不起作用...我想在页脚中显示行的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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