Sql – Deleting a record ( using GridView )

asp.netnetsql

1) Why can we update data records ( via data source control ) without setting GridView.DataKeyNames property, but when deleting ( and if ConflictDetection property is set to the OverwriteChanges ), DataKeyNames must be set, else GridView will not pass parameters to data source control?

Thank you

Best Answer

GridView uses DataKeyNames as identifiers to the records that you want to manipulate. Just like primary keys on your tables. They're roughly used on WHERE clause of your operation.