Sep 2, 2010

GridView problems with Editing and Updating

Symptoms:
  • RowUpdated handler does not fire
  • UpdateMethod in DataSource does not fire
  • GridViewUpdateEventArgs empty in the RowUpdating handler
All of these are caused by a problem in the binding of the DataSource object to the GridView.

Solution:
  1. Check that your DataSourceControl has been added to the page controls. (ej. Panel1.Controls.Add(objectdatasource);
  2. Bind your Datasource to the GridView with: Gridview.DataSourceId = datasource.Id;
  3. Do NOT bind your DataSource to the GridView using: Gridview.Datasource = datasource;