数据集,数据行和数据列 [英] Dataset,Datarow and DataColumn

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

问题描述

嗨...
我正在使用asp.net和c#开发一个Web应用程序.
我正在检索数据集中的数据为:
结果期内总计
结果1 4 10
结果2 8 20
成果3 3 19

我正在从结果管理员那里检索所有结果1,结果2 ..
这里将显示所有不同的结果.
同样,在期间和总计字段中,我正在检索该时间段内该结果的计数以及从查询表中检索的总计计数.
现在我的问题是我想计算数据集内所有结果的周期内列和总和下的总和.
应该是:
结果期内总计
结果1 4 10
成果2 8 20.
成果3 3 19
总计(应该为以上所有结果计算该值).
如何计算最后一行中所有数据行值的总和.

Hi...
I am developing a web application using asp.net and c#.
I am retrieving data in Dataset as:
Outcome WithinPeriod Total
Outcome1 4 10
Outcome2 8 20
Outcome3 3 19

I am retrieving all the Outcome1,Outcome2..from Outcome master.
Here all the distinct Outcomes will be displayed.
Also in withinperiod and Total Field,I am retrieving count of that outcome withing that period and Total count from Enquiry Table.
Now my problem is that i want calculate total sum under column withinperiod and Total for all outcome in dataset.
it should be:
Outcome WithinPeriod Total
Outcome1 4 10
Outcome2 8 20.
Outcome3 3 19
Total(This value should be calculated for all above outcome).
How to calculate sum of all datarow values in last row.

推荐答案

根据我的说法,您无法在最后一行中获得总计,但是可以使用for或foreach循环来实现将获得temp变量中的total,然后您可以在yr数据表中添加一行,并在InsidePeriod和total中分别添加"total"结果n中的某些结果.
According to me you can not get total of it in last row but yes using for or foreach loop you will get total in temp variable and after that you can add one row in yr datatable with "total" Outcome n some in WithinPeriod and total respectively.


您可以通过这种方式获取数据:
1.您可以通过sql获取行数据并绑定datatable.
2.您可以总计需要sql归档的列并保存到dataRow,例如:
选择sum(Column1),...
3.最后,将dataRow数据添加到datatable.


希望此建议对您有所帮助.
you can get data by this way:
1. you can get rows data by sql and bind datatable.
2. you can total you need column filed by sql and save to dataRow, eg:
select sum(Column1),...
3. at last you add dataRow data to datatable.


hope this suggestion help u.


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

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