'CommitNew' is not allowed for this view Exception

i get this annoying Error :

‘CommitNew’ is not allowed for this view.

when i try to submit a Cell Value on a WPF DataGrid to the database, somehow the database query code is working fine, and the database is updated successfully. but then afterwards the Application crushes and the Debugger doesn’t highlight any code at all.

I looked around the internet but couldn’t find any helpful resources at all. Can anyone who had dealt with similar case to please explain what is the issue behind that error, and how can i solve it.

1 Like

That means you’ve Overridden your DataGrid Cell Template (somehow) and the new Template is messing out the Edit-ability of your Cells.

I suggest that you check these:

  1. Check that you didn’t override the default Cell Template, in case you did make sure that your new Cell Template implements it in a way similar to the default one. especially when it comes to the edit-ability feature and its data/template bindings (notice that the default Cell Template uses a TextBox as the editing zone).

  2. In case you are using some 3rd Party UI Library or Themes, make sure that they aren’t replacing your default DataGridCell Template, Poorly written libraries can cause that with broken Bindings or Wrongly implemented Cell Templates.

Finally; It can be really easy to edit your DataGridCell Template by just using the tools provided by Visual Studio itself. Follow these easy steps to:

  1. Right-Click your Control on the Designer.
  2. Click the Menu Item Under “Edit Additional Templates” > “Edit Cell Style” > “Edit a Copy…”.
  3. Fill in the Style name and where you want it to be placed (e.g. App.xaml, a Theme Resources Dictionary or within the current file…etc).
  4. That should be enough to generate a new XAML Style for your DataGridCell, go and Modify its Template.