逐行获取datagride中的总和 [英] get sum in datagride row by row

查看:86
本文介绍了逐行获取datagride中的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在vb net中的行末求和,我在datagride中输入了一些值.不在列的底部,我需要它在行的最后一个单元格.im对此项目不使用sql连接. ''m只需要显示sum.im uising vb.net 2008
请hlp me

i need get sum to end of the row in vb net whem im enter some of values into datagride.not to bottom of column,i need it to last cell of the row.im not using sql conection for this project.i''m need only display sum.im uising vb.net 2008
pls hlp me

推荐答案

小数总计;

开启DataGrid的ItemDataBound
if(e.Item.ItemType == ListItemType.Item || ListItemType.AlternatingItem)
{
Total + = Convert.ToDecimal(e.Item.Cells [yourCellIndex] .Text);
}
否则if(e.Item.ItemType == ListItemType.Footer)
e.Item.Cells [yourCellIndex] .Text = Total.ToString

注意:上面的代码在C#中
decimal Total;

ON ItemDataBound of DataGrid
if(e.Item.ItemType==ListItemType.Item || ListItemType.AlternatingItem)
{
Total+=Convert.ToDecimal(e.Item.Cells[yourCellIndex].Text);
}
else if(e.Item.ItemType==ListItemType.Footer)
e.Item.Cells[yourCellIndex].Text=Total.ToString

Note: Above code is in C#


这篇关于逐行获取datagride中的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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