Search code examples
c#asp.netgridviewdatakey

How to prevent duplicate data in the grid view?


I have a grid view and this grid view has a DataKeyNames="person_id"

Now I want this key as a primary key for the grid so no allowed duplicates .

How to prevent duplicate data through using DataKeyNames


Solution

  • GridView is a presentation layer. It should not do any validation. I suggest you to check for duplicates in Data Access layer.