none
DataGrid doesn't handle data source errors!? RRS feed

  • Question

  • Hi,

    My data source, a data table, throws an error if the data of that row is used by other consumer is deleted.

     

    This is implemented in the DataRowDeleting event handler of the data table. It checks if that row can be deleted, and if now throws an application error.

     

    The problem is when the user deletes a row in the grid that can't be deleted, the application crashes with an unhandled error!

     

    The DataGrid doesn't have a DataError Event, as has DataGridView I used in the .NET Framework 2.0. In that grid the DataGridViewDataError was thrown and I could handle the error there, including setting the property Cancel of the DataGridViewDataErrorEventArgs to False, cancelling this way the deletion.

     

    How can I do this in the System.Windows.Controls.DataGrid (.NET Framework 4)?

    If it isn't possible, does Microsoft have intention to implement it?

     

    This is an issue because sometimes we just can’t control the data source and it always can throw an error for many reasons.

    Regards,

    Pedro Gonçalves

    Wednesday, July 28, 2010 4:07 PM