Cannot use 'Parse' as an argument to a dynamically dispatched operation - Multiple Media Picker
Hi There,
I am trying to get the first image from a multiple media selector control. I am doing this in a partial View that gets all the children of type "Listing" and displays a widget of the listing with the first image in the Images property .
I built the partial view from one of the templates in umbraco and I am using version 7.5.3. There are no customisations and this is a fresh install.
Thanks for getting back to me. I tried this and its still giving the same error. To try and debug the problem i tried to do the tostring() on just the images and it says that its already a string. and the output looks like
1086,1087,1088,1089,1090,1091,1092,1093,1094,1095
I even just tried taking out the select statement and getting the FirstOrDefault item from the string array and its telling me that "System.Array" does not contain a definition for FirstOrDefault.
By the look of it its not liking Linq functions. I even tried adding using System.Linq to the page and it still did nothing.
Do you have any idea what the issue could be. hopefully yhe above will help narrow things down.
Cannot use 'Parse' as an argument to a dynamically dispatched operation - Multiple Media Picker
Hi There,
I am trying to get the first image from a multiple media selector control. I am doing this in a partial View that gets all the children of type "Listing" and displays a widget of the listing with the first image in the Images property .
I built the partial view from one of the templates in umbraco and I am using version 7.5.3. There are no customisations and this is a fresh install.
Any assistance will be greatly appreciated.
}
Hi Andrew,
Try to use this code:
instaed of this one:
item is dynamic type, I think this is the problem. Also we can rewrite all your view to strongly typed, what do you think is better for you?
Thanks,
Alex
Hey Alex,
Thanks for getting back to me. I tried this and its still giving the same error. To try and debug the problem i tried to do the tostring() on just the images and it says that its already a string. and the output looks like
1086,1087,1088,1089,1090,1091,1092,1093,1094,1095
I even just tried taking out the select statement and getting the FirstOrDefault item from the string array and its telling me that "System.Array" does not contain a definition for FirstOrDefault.
By the look of it its not liking Linq functions. I even tried adding using System.Linq to the page and it still did nothing.
Do you have any idea what the issue could be. hopefully yhe above will help narrow things down.
CHeers Andrew
Hi Andrew,
It's really strange issue, what version of Umbraco are you using?
This is working for me:
Thanks,
Alex
Hi Andrew,
Di you find a solution?
Can you share with community?
Thanks,
Alex
Apologies for the delay in posting the solution.
The solution was to get the images and post them to an array and the grab the first item in the array.
Split the Multiple media collection
And then read the first item of the array.
Hi Andrew
Thank you for sharing!!!
Have a nice day
Alex
is working on a reply...