Completed
Last Updated: 11 Feb 2014 13:56 by ADMIN
ADMIN
Georgi I. Georgiev
Created on: 19 Jul 2013 04:16
Category: GridView
Type: Bug Report
2
FIX. RadGridView - deleting row in a self-referencing grid throws null reference exception
To reproduce :
Create a self-referencing hierarchy, bind it to a BindingList and delete the row with either the delete button or from the context menu and click the deleted item. 
Workaround :
Find the object that has to be deleted, hide the selected row and remove the found object from the data source.
void radGridView1_UserDeletingRow(object sender, GridViewRowCancelEventArgs e)
{
    e.Cancel = true;
    int id = int.Parse(e.Rows[0].Cells["Id"].Value.ToString());
    var human = this.humans.FirstOrDefault(x => x.Id == id);
    if (human != null)
    {
        this.radGridView1.SelectedRows[0].IsVisible = false;
        this.humans.Remove(human);
    }
}
0 comments