If there's nothing picked I would expect the code not to run but it comes back with an error "System.ArgumentNullException: Value cannot be null." on the selection var. I have also tried .Count() but does the same thing.
The .ToArray() will throw an exception if nothing is picked because the .Value request returns Null if nothing is picked, not an empty IEnumerable. And that causes the problem you are seeing. So instead of checking count, you need to check for null.
Multinode Treepicker - Value cannot be null
Hi, I'm using the following to get MNTP values:
If there's nothing picked I would expect the code not to run but it comes back with an error "System.ArgumentNullException: Value cannot be null." on the selection var. I have also tried .Count() but does the same thing.
Has anyone got any suggestions?
Thanks
Hi Nathan,
If only one item has been selected in MNTP - then you have to use Model.Value
Probably this code should work:
Thanks,
Alex
The issue lies in this line:
The
.ToArray()
will throw an exception if nothing is picked because the .Value request returns Null if nothing is picked, not an empty IEnumerable. And that causes the problem you are seeing. So instead of checking count, you need to check for null.Thanks
Nik
Thanks Nik
Thanks both for the quick reply. I have it working now using:
Cheers
is working on a reply...