Search code examples
asp.netgridviewsqldatasource

gridview and sqldatasource control in asp.net


i have a gridview which is populating from sql datasource defined at designed, i have configured sqldatasource to select, update and delete, i have a title field in my table which is primary key, it was working fine and updating the records too. until i removed the boundfields and placed templatefield and itemtemplate. after that i gets an error saying:

You have specified that your update command compares all values on SqlDataSource 'SqlDataSource1', but the dictionary passed in for oldValues is empty. Pass in a valid dictionary for update or change your mode to OverwriteChanges.

if i make the ConflictDetection = "OverwriteChanges" it works fine but does not update.. the requirement for the itemtemplate is because i want to display footer template for new records and change the default edit and delete button to imagebutton...

How should i make it work using itemtemplate...


Solution

  • you can add the columns you want persisted by adding them to the gridview datakeynames collection.