怎么得到列的总和 [英] how get total of column

查看:66
本文介绍了怎么得到列的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Table name collection
Sr. No.	Name	Amount
1	Mahima	45
2	Aman	56
3	Raj	78





i希望得到.aspx页面输出顶部的Amount列总数你能解释一下如何在aspx.cs页面中编写代码可以帮助我编码吗? ??



i want to get total of Amount column at the top of .aspx's page output can you explain me how write coding in aspx.cs page can you help me for coding ???

推荐答案

看看这里: ASP.NET 2.0的GridView示例:在页脚中显示摘要数据 [ ^ ]



您可以使用Google!


注意:如果你是使用System.Data.DataTable然后你可以使用这个解决方案



NOTE: If you are use System.Data.DataTable then you can use this solution

decimal total = 0;
          for(int i=0;i            {
              total += Convert.ToDecimal(dt.Rows[i][2]);
          }
          txtTotal.Text = total.ToString();





在aspx页面中定义:



In the aspx page define this:

<p><asp:label text="Total Amount : " runat="server" xmlns:asp="#unknown"></asp:label><asp:textbox id="txtTotal" runat="server" enabled="false" xmlns:asp="#unknown"></asp:textbox></p>





用Page_Load或其他方法包装计算以显示数据。





希望这会有所帮助。



Wrap the calculation in Page_Load or the other method to display data.


Hope this will help.


这篇关于怎么得到列的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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