汇总gridview的页脚中的总计 [英] Summarizing Totals in Footer of gridview

查看:98
本文介绍了汇总gridview的页脚中的总计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从数据库中获取值
在gridview内
并在其中
的单元格中分配一个-"字符串 值为空
我想总结一下gridview页脚中的值
没有null或"---"
时运行良好 在行单元格中
但是我无法对包含"---"的行进行求和


我已经尝试过

I am fetching Values from database
inside a gridview
and assigning a "---" string in the cells where
value is null
I want to summarize the values in the footer of the gridview
its running fine when there is no null or "---"
in the row cells
But i am not able to sum the rows containing "---"


i have tried

If e.Row.RowType = DataControlRowType.DataRow Then

            sum = sum + Convert.ToDecimal(e.Row.Cells(1).Text))
        ElseIf e.Row.RowType = DataControlRowType.Footer Then

            e.Row.Cells(0).Text = "Total"
            e.Row.Cells(1).Text = sum.ToString()
            e.Row.Font.Bold = True
            e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Right
        End If


我如何实现此


how can i achieve this

推荐答案

添加前添加检查

if((e.Row.Cells(1).Text).TOString())!="---")
sum = sum + Convert.ToDecimal(e.Row.Cells(1).Text))
Add check before addition

if((e.Row.Cells(1).Text).TOString())!="---")
sum = sum + Convert.ToDecimal(e.Row.Cells(1).Text))




以下链接可能会为您提供帮助:

http://msdn.microsoft.com/en-us/library/bb310552.aspx [ ^ ]


http://forums.asp.net/t/998134.aspx [
Hi,

Following links might help you:

http://msdn.microsoft.com/en-us/library/bb310552.aspx[^]


http://forums.asp.net/t/998134.aspx[^]


这篇关于汇总gridview的页脚中的总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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