foreach (var item in sizecollection.OrderBy("Parent.wwwidth"))
{
@item.Parent.wwwidth
}
this returns an error "Sequence contains no elements"
this...
foreach (var item in sizecollection.OrderBy("Parent.Name"))
{
@item.Parent.wwwidth
}
Does what you would expect and orders the nodes by their parents names.
all nodes in sizecollection has a parent with a nonempty property with the alias "wwwidth".
"error CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type"
var id = Request.QueryString["id"];
var product = Umbraco.Content(id);
var sizelist = product.wwstr.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var sizecollection = Umbraco.Content(sizelist);
OrderBy selfmade property on parentnode razor
Im trying to order a list of nodes..
this returns an error "Sequence contains no elements"
this...
Does what you would expect and orders the nodes by their parents names. all nodes in sizecollection has a parent with a nonempty property with the alias "wwwidth".
Thanks in advance.
I would do it using LINQ like this:
Assuming that wwwidth is an int. If it was a string you'd use
GetPropertyValue<string>
instead.Hello Dan
Your answer gives me:
"error CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type"
Hi Simon,
How are you declaring sizecollection? Is it a typed object or a dynamic object. I suspect it is dynamic based on the error you are getting.
Thanks,
Nik
Hi Nik
Its dynamic.
So, if you use a non-dynamic way to initialise
sizecollection
then my code should work, I think. So try:That worked.
Thanks
is working on a reply...