如何计算数据网格视图中的所有数据并将其放在listview中的列上 [英] How do i count all the data in the data grid view and put it on a column in the listview
问题描述
我有一个资产清单,除了序列号之外,它们会有类似的信息。现在每个资产只有一个数量。
| 名称 | 数量 | serial |
|显示器| 1 | ADJ1DAJAK |
|显示器| 1 | AMBJA1ASL |
这是一个示例表。我的问题是如何在列表视图中显示它看起来像这样:
| 可用数量 | 名称 |
| 2 |显示器|
我尝试过的事情:
我的想法虽然是创建一个搜索功能,以便将一组相同的资产显示到数据网格视图,然后从数据网格视图中我将计算行并显示列表视图中的所有计数。
I have a list of assets which will have similar information except for the serial number. Now each of these assets have only one quantity.
|Name|Qty|serial|
|Monitor |1 |ADJ1DAJAK |
|Monitor |1 |AMBJA1ASL |
this is a sample table. My problem is how could I display it in a list view that it will look like this:
|Qty Available|Name|
| 2|Monitor |
What I have tried:
My idea though is to create a search function so that a group of the same assets will be displayed unto the data grid view then from the data gridview i would count the rows and display the over all count in the listview.
推荐答案
如果您的SQL表与您的第一个示例类似,那么您可以从中获取所需的信息。以下查询应返回它:
If your SQL table is similar to your first example then you can get information you need just from it. Following query should return it:
SELECT Count(*) AS QtyAvailable, Name
FROM TableName
GROUP BY Name
这篇关于如何计算数据网格视图中的所有数据并将其放在listview中的列上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!