消除Gridview中的重复行. [英] Eliminating Duplicate rows in Gridview.
问题描述
我的要求就像我在GridView中有9列.那时每行中都将存在重复的值,我必须显示第一个值和我需要禁用的其他行值.如果数据不是重复的,我必须按原样显示数据行.这适用于所有9个列.我的意思是,如果任何行数据被重复,那么我必须仅显示一个,而其他应禁用.任何人都可以遇到这种要求吗?如果是,请提出解决方案.
我在Rowdatabound中尝试了一些可以处理1或2个列的逻辑,但并非对所有列都一样.任何人都可以帮忙.谢谢
Hi, My requirement is like I have 9 columns in a GridView.Duplicate values will exist in Each row at that time i have to display first value and other row values i need to disable. If data is not duplicate i have to show dat row as it is. This applies to all the 9 colums. I mean if any of the row data is getting repeated then i have to show only one and others should be disabled. Can anyone come across this type of requirement ?? If Yes please sugest the solution.
I tried in Rowdatabound with some logicam able to do for 1 or 2 colums but same is not happening for all the colums. Can anyone help on this. Thanks
推荐答案
在linq中使用SELECT DISTINCT将它们绑定之前将其删除
如
Remove them before they are bound by using SELECT DISTINCT in linq
such as
public void Linq46()
{
int[] factorsOf300 = { 2, 2, 3, 5, 5 };
var uniqueFactors = factorsOf300.Distinct();
Console.WriteLine("Prime factors of 300:");
foreach (var f in uniqueFactors)
{
Console.WriteLine(f);
}
}
http://msdn.microsoft.com/en-us/vcsharp/aa336761.aspx#distinct1 [^ ]
http://msdn.microsoft.com/en-us/vcsharp/aa336761.aspx#distinct1[^]
这篇关于消除Gridview中的重复行.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!