Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how i remove repetition of data in any gridview?
Posted

The way you would do this in the GridView is to look at each row as it is inserted, and check to see if the row is a duplicate of any other row (in a column by column comparison). It isn't pretty, but it is the best there is once you get to this point. Here is a couple of links that will help you with the code:

http://social.msdn.microsoft.com/Forums/en-AU/csharpgeneral/thread/d4ef2cfd-99e0-43e8-a274-d7bf2568d494[^]

http://stackoverflow.com/questions/8717898/datagridview-find-duplicate-rows-and-update-existing-data[^]

The better way of doing this is to remove the duplicates before you get the data to the GridView. Use a better SQL query (such as SELECT DISTINCT) to get your data. This way you can load your data directly without the expensive overhead of looping through each record. Also, since you did your duplicate removal at the database server, you will have transmitted less data to the client, thus saving yourself even more overhead.
 
Share this answer
 
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900