Click here to Skip to main content
Rate this: bad
good
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 17:18pm
Edited 13-Apr-13 20:18pm
v4
Rate this: bad
good
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.
 
—SA
  Permalink  
Comments
Abhinav S at 14-Apr-13 2:02am
   
5!
Sergey Alexandrovich Kryukov at 14-Apr-13 2:47am
   
Thank you, Abhinav.
—SA
Rate this: bad
good
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.
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 14-Apr-13 2:49am
   
Agree, a 5.
—SA
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 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Maciej Los 250
3 Shweta N Mishra 216
4 PIEBALDconsult 174
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,665


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 14 Apr 2013
Copyright © CodeProject, 1999-2014
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