Completed
Last Updated: 27 May 2015 13:18 by Ruth Goldberg
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 07 Feb 2014 14:41
Category: GridView
Type: Bug Report
2
FIX. RadGridView - the DataError event is not fired when System.Data.ConstraintException occurs while editing
To reproduce:
-add a RadGridView and bind it to Northwind.Customers datatable.
-try to edit a random row and change its CustomerID cell to an already existing one.

Workaround: use custom GridViewDataRowInfo:

public class CustomRowInfo : GridViewDataRowInfo
{
    public CustomRowInfo(GridViewInfo viewInfo) : base(viewInfo)
    {
    }

    protected override bool OnEndEdit()
    {
        IEditableObject dataItem = this.DataBoundItem as IEditableObject;
        if (dataItem != null)
        {
            try
            {
                dataItem.EndEdit();
            }
            catch (Exception ex)
            {
                this.ViewTemplate.SetError(new GridViewCellCancelEventArgs(null,null, null), ex);
            }
        }
    
        return base.OnEndEdit();
    }
}
1 comment
Ruth Goldberg
Posted on: 15 Jan 2015 19:03
I prefer to set EnforceConstraints = false for the dataset as my workaround since I am doing my own enforcing anyway.