BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
Hi, a google search led me here as I was having the same problem.
I have a grid where I change the ItemsSource quite frequently along with the SelectedItem to match the updated ItemsSource.
I've spent a lot of time trying to debug it and found that the selection state isn't managed properly. What happens is the header row is set as the selected row at some point (I am unsure why it's doing this but believe it has something to do with the modified ItemsSource as well as the SelectedItem being set to null) and then internally during InvalidateSelectionOfRow it iterates over the internal rows to try match it with the changing row, but with the header being set as the selected row, the Contains is called:
r.IsSelectedRow && !base.SelectedRows.Contains(r.RowData)
but r.RowData is null because it's the header row and this in turn calls the Find method which then throws the exception:
internal GridRowInfo Find(object rowData)
{
if (rowData == null)
{
throw new InvalidOperationException("RowData is null in Find is not valid operation");
}
if (base.Count <= 0)
{
return null;
}
return this.FirstOrDefault((GridRowInfo rowInfo) => rowInfo.RowData == rowData);
}
This is still a problem on the version I'm using v20.2.0.46
To work around this I made sure to never set the SelectedItem to null. This seems to prevent the exception from occurring. It's messy. I hope this helps someone.
Attached is a sample app replicating this - click Next a few times and at the point that we set the SelectedItem as null, that's when it will throw the exception
Hi Malcolm,
We would like to let you know that we are able to replicate the reported scenario on our end. We will update you with further details on or before October 13, 2022. We appreciate your patience until then.
Regards,
Suja
Hi Malcolm,
We have logged a bug report for the reported issue “InvalidOperationException thrown when changing SelectedItem as null during runtime ". We will fix the issue and include the fix in our weekly nuget which is scheduled on November 8, 2022. We will let you know once it is released with the fix. You can also track the status of the report from the below link.
Feedback link: https://www.syncfusion.com/feedback/38383/invalidoperationexception-thrown-when-changing-selecteditem-as-null-during-runtime
Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.
Regards,
Suja
We are glad to announce that our Essential Studio 2022 Volume 3 Service Pack Release V20.3.0.56 is rolled out with fix for the issue "InvalidOperationException thrown when changing SelectedItem as null during runtime” and it is available for download under the following link.
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.