Hi,
I think the items in the DataGrid are not of DataRowView type, you can set use the following code to check whether the item you get is null, if it's not null, check its type.
private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
if (e.Row.Item != null)
{
// Check the item type
Console.WriteLine(e.Row.Item.GetType().Name);
// If the item is for example of MyClass type, you can do the casting as follows:
// MyClass itemdata = e.Row.Item as MyClass;
}
}
If anything is unclear, please feel free to let me know.
Best Regards,
Zhi-Xin Ye
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!