Click here to Skip to main content
11,721,385 members (81,072 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# .NET
How to check an item already entered in a listview if i am entering data from a combo box from two tables for an id as value member based on group...I mean there is both software id and asset id that can be added in the listview based on the group software and hardware....If software software item with software id else asset item with asset id will be added to listview....How to check duplicate items while adding to listview if so....
Posted 13-Apr-13 16:18pm
Edited 13-Apr-13 19:18pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Wrong approach. Prepare a data set which already does not contains duplicates and populate the control with it. Better yet, think why do you have duplicates in first place and think if you can prevent it. Base all you logic on data, not controls showing data.

Abhinav S at 14-Apr-13 2:02am
Sergey Alexandrovich Kryukov at 14-Apr-13 2:47am
Thank you, Abhinav.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You can use LINQ to select distinct rows before assigning the source to the listview.
If you are using a sql query to build your source from a database, do the distinct filtering on the query side for enhanced performance.
Sergey Alexandrovich Kryukov at 14-Apr-13 2:49am
Agree, a 5.
Abhinav S at 14-Apr-13 2:54am
Thank you SA.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 380
1 OriginalGriff 254
2 Mika Wendelius 170
3 cyycoish 70
4 ppolymorphe 66
0 Sergey Alexandrovich Kryukov 2,249
1 OriginalGriff 1,024
2 F-ES Sitecore 690
3 Maciej Los 619
4 Richard MacCutchan 580

Advertise | Privacy | Mobile
Web03 | 2.8.150901.1 | Last Updated 14 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100