Extract New Addition from Gridview


New member
Aug 17, 2017
Programming Experience
In sql i have a table called PFMembers that keeps members of a provident fund and their ids, eg a table with name Bob with User ID 1 and Lisa with ID 2 say the next month i am supplied a list that contains same list of members (in my PFMembers) plus additional new members eg Rich with user ID 3 which are not registered in my PFMember table , (due to size of the list i may not know these new names). in my c# program, i have two gridviews, one will display the upload from excel which will contain both members registered in my PFMember and the new additional members (Bob,Lisa,Rich), my question is i want to display in the 2nd gridview those new additional members (Rich). (this new members are no where in an sql table but just displayed in a gridview)
Firstly, there are GridView controls for both Web Forms and WPF. You have posted in the C# General forum when clearly your question relates to either Web Forms or WPF, both of which have dedicated forums. Please post in the most appropriate forum for the topic, not the most general one. If you let us know which it is, we can move this thread there.

That said, the answer may be unrelated to the presentation technology in use anyway. Basically, you will start with a list of all the incoming records and you need to filter out the ones that have an ID that is already in the database. To do that, you need to get a list of all the IDs in the database, which is a simple query. You can then do whatever is appropriate for the type of list you have. That might mean looping through the list of existing IDs and, for each one, looping through the list of incoming records and removing one if you find a matching ID. It might also mean a simple LINQ query:
var newRecords = allIncomingRecords.Where(record => !existingIDs.Contains(record.ID))

Whatever you do, it's done before you have to consider how to display the data to the user, so the GridView isn't actually relevant. That being the case, perhaps C# General is, either intentionally or accidentally, the most appropriate forum. In that case though, you should still specify the technology you're using. You should also what data structure the data is currently stored in, because the specifics of filtering the data may well depend on that.
Top Bottom