Tuesday, January 3, 2012

ASPxGridview Error: LinqDataSource '' does not support the Update operation unless EnableUpdate is true

When using ASPxGridview binded to a LinqServerModeDataSource, make sure that EnableUpdate is set to false when you are handling the update in the rowupdating event. I was getting the error

LinqDataSource '' does not support the Update operation unless EnableUpdate is true

because I forgot to add the following lines in the rowupdating event, which tells the grid that the event has been handled. Omitting these 2 lines causes the code to think that the update needs to be handled by the linqdatasource, which results in the above error

void MyGrid_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
{
   //Code to update, example:
   //int pb_pk; int.TryParse(Convert.ToString(e.Keys[0]), out pb_pk);
   //int pb_w3_Budget_fk; int.TryParse(Convert.ToString(e.NewValues["pb_w3_Budget_fk"]), out pb_w3_Budget_fk);
   //SqlDataProvider.PurchasingBudgets_Update(pb_pk, pb_w3_Budget_fk);
   e.Cancel = true;
   (sender as ASPxGridView).CancelEdit();
}


No comments:

Post a Comment