GridView and DataKeyNames

If you're trying to create a gridview, automatically bound to either a SqlDataSource or an ObjectDataSource (the better of the two options), and want edit and delete functionality, do not forget to set the DataKeyNames property to the primary key of the table or object you are trying to delete. Otherwise Edit/Update seems to work, but Delete will complain that it cannot find the parameter, even if you are defining DeleteParameters in the DataSource itself.

8 Comments

Comments have been disabled for this content.