views:

560

answers:

1

Hi

Use the DataKeyNames property to specify the field or fields that represent the primary key of the data source. You must set the DataKeyNames property in order for the automatic update and delete features of the GridView control to work.

a) According to above quote Update should only be possible if DataKeyNames is set, and yet I was able to update database even though I don’t have DataKeyNames set.


b) Or does the term automatic update mean something else?


Thank you

+1  A: 

A GridView or a Formview can support automatic updates, only if it is used with some kind of a properly configured *Datasource (ObjectDataSource, SqlDataSource etc.). For delete/update operation, a unique key is required, hence the DataKeyNames collection. If the DataSource is for example a Strongly typed dataset, it is working automatically out of the box.

balint
What does the term automatic updating mean? That we don’t need to supply Update sql statement (when using SqlDataSource), but instead SqlDataSource will be able to update database non the less?
PrgGnt
balint