Gridview 列和行总计
我的 gridview 有如下所示的数据(例如)
col1 col2 col3
2 10 1
4 3 5
11 15 18
我想做的是...按行和列执行求和并向网格添加另一列...所以最终它看起来像下面
col1 col2 col3 Total
2 10 1 13
4 3 5 12
11 15 18 44
17 28 24
这样是否可以C#。你能让我知道我该怎么做吗?
是不是这样,我必须按行和列解析网格,然后执行 SUM?像下面
foreach (gridviewrow row in gridview1.rows)
{
add the value for cell 0;
cell 1;
cell 2;
}
有没有更好的 wau 来实现这个目标?多谢。
谢谢, 拉胡尔
my gridview has data which looks like below (for example)
col1 col2 col3
2 10 1
4 3 5
11 15 18
What I am trying to do is ... performing a sum by Row and Column and add another column to grid ... So that ultimately it will looks like below
col1 col2 col3 Total
2 10 1 13
4 3 5 12
11 15 18 44
17 28 24
Is it pssible in C#. Can you please let me know how can I do this.
is it like, I have to parse through the grid by Row and Column and then perform the SUM; like below
foreach (gridviewrow row in gridview1.rows)
{
add the value for cell 0;
cell 1;
cell 2;
}
Is there any better wau to achive this? Thanks a lot.
Thanks,
Rahul
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我终于得到了它,所以,考虑将其发布......如果它对其他人有帮助的话。
我没有处理来自网格的数据...我将 Sum 的逻辑放入我的处理中,然后将该数据绑定到网格...这有效。
也可以在 gridview 中完成...我们必须将处理放在“gridview_onrowdatabound”事件中,如下
希望这有帮助。
谢谢,
拉胡尔
Well I have got it finally and So, thought of posting it ... if it helps others.
Instead of processing the data from grid ... I put the logic for Sum in my processing and then bind that data to grid ... which worked.
Can be done in gridview as well ... we have to put the processing in "gridview_onrowdatabound" event as below
Hope this Helps.
Thanks,
Rahul