简体   繁体   English

用一行过滤gridview数据

[英]Filter gridview data with one row

I am getting records from three tables in grid-view. 我从网格视图中的三个表中获取记录。

Here two table data is always the same but one table data shows different records I want to show third table data in one row in grid-view, when third table data gets the record then it needs to be filtered with comma separated using c#. 在这里,两个表数据始终是相同的,但是一个表数据显示了不同的记录,我想在网格视图的一行中显示第三个表数据,当第三个表数据获得记录时,则需要使用逗号分隔并使用c#进行过滤。

您将必须根据需要创建自定义数据表,并将该数据表绑定到gridview。

您可以将返回结果存储在列表中,并在绑定到网格之前对其进行过滤。

you need to use the union in your query to avoid the duplicate records rather than doing after binding the records. 您需要在查询中使用并集来避免重复记录,而不是在绑定记录之后执行。

You may get 50 records from the database but after removing the duplicates you may have just 5 to 10 records so why you want to get the 50 records, why can't remove them at the time of querying them. 您可能会从数据库中获得50条记录,但是在删除重复项之后,您可能只有5到10条记录,因此为什么要获得50条记录,为什么在查询时无法将其删除。

Use something like this: 使用这样的东西:

select x, y, z from Table1
Union
select x, y, z from Table2    
Union
select x, y, z from Table3

It will always give you the ditinct records. 它将始终为您提供不同的记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM