如何在asp.net C#中减少Gridview列值 [英] How to decrease Gridview Column value in asp.net C#
问题描述
使用我的代码,但此代码gridview减少值错误输出请如何减少源代码中的所有值。
我的代码:
Using My code but this code gridview decrease value wrong output pls how to decrease all values in source code.
MY CODE :
int i = 0;
int permissionhrs = 180;
foreach (GridViewRow gvRows in gvLatemints.Rows)
{
total2 = Convert.ToInt32(permissionhrs.ToString()) - Convert.ToInt32(gvRows.Cells[2].Text.Trim());
lblError.Text = "Total Leave :" + total2;
i++;
}
示例gridview列下面的Mints值
所以许可小时180比网格列mints列明智减少
处理日期LateIN Mints
2014年3月8日17 15
2014年3月10日11 15
2014年3月13日17 15
2014年3月14日21 30
2014年3月18日27 30
2014年3月22日19 15
ex:
总计= 180 -15,
回答= 165
所以这个循环执行所有Mints值减少
最后我想要结果是:60分钟可以在许可小时内获得
谢谢
Example gridview column Mints values below
So Permission Hours 180 decrease above gridview column mints column wise
Process Date LateIN Mints
08 Mar 2014 17 15
10 Mar 2014 11 15
13 Mar 2014 17 15
14 Mar 2014 21 30
18 Mar 2014 27 30
22 Mar 2014 19 15
ex:
total=180-15,
answer=165
so this loop wise execute all Mints Values decrease
finally I want Result is:60 mints available in permission hrs
Thanks
推荐答案
尝试这样的希望这将是有效的对你来说。
Try Like this hope this wil work for you.
int i = 0;
int permissionhrs = 180;
int permissionResult=permissionhrs ;
foreach (GridViewRow gvRows in gvLatemints.Rows)
{
total2 = permissionResult - Convert.ToInt32(gvRows.Cells[2].Text.Trim());
lblError.Text = "Total Leave :" + total2;
permissionResult=permissionResult - Convert.ToInt32(gvRows.Cells[2].Text.Trim());
i++;
}
这篇关于如何在asp.net C#中减少Gridview列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!