Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
Is it possible in Razor to check if a node is the last node in a dynamicnodelist?
This is my code:
foreach (var id in networkitem.networkAssociatedMember)
{
dynamic member = new DynamicNode(id.InnerText);
if (networkitem.networkAssociatedMember.Last())
@( member.nodeName);
}
else
@(member.nodeName + ", ");
As you can see to check if the node in the DynamicNodeList is the last node, I'm trying Last() , but this isn't working.
thanks for your help,
Anthony
Solved it, the methodname is: IsLast()
@if(networkitem.HasValue("networkAssociatedMember"))
if (networkitem.networkAssociatedMember.IsLast())
Oops, seems like I was too optimistic. The method IsLast() isn't working, the condition is passed.
ok, I found documentation about the IsLast() method of the DynamicNode object:
Umbraco Razor Feature WalkthroughâPart 7
However, when I try this code:
DynamicNode member = new DynamicNode(id.InnerText);
if (member.IsLast())
@(member.Name);
@(member.Name + ", ");
This condition that checks if a DynamicNode is the last in the set is still passed, so that the outcome is rendered like this:
(associatedmember, associatedmember,)
while it should be
(associatedmember, associatedmember)
why is this not working?
Hi Anthony,
Did you get this sorted ou ? Am having the same issue here
@Fuji, seems the IsLast() is the method to check if a dynamic is the last item in a collection. See also this post:
http://our.umbraco.org/forum/developers/razor/33671-Display-last-item-from-media-folder
greetings,
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
check for last node in dynamicnodelist
Hi,
Is it possible in Razor to check if a node is the last node in a dynamicnodelist?
This is my code:
foreach (var id in networkitem.networkAssociatedMember)
{
dynamic member = new DynamicNode(id.InnerText);
if (networkitem.networkAssociatedMember.Last())
{
@( member.nodeName);
}
else
{
@(member.nodeName + ", ");
}
}
As you can see to check if the node in the DynamicNodeList is the last node, I'm trying Last() , but this isn't working.
thanks for your help,
Anthony
Solved it, the methodname is: IsLast()
@if(networkitem.HasValue("networkAssociatedMember"))
{
foreach (var id in networkitem.networkAssociatedMember)
{
dynamic member = new DynamicNode(id.InnerText);
if (networkitem.networkAssociatedMember.IsLast())
{
@( member.nodeName);
}
else
{
@(member.nodeName + ", ");
}
}
}
Oops, seems like I was too optimistic. The method IsLast() isn't working, the condition is passed.
ok, I found documentation about the IsLast() method of the DynamicNode object:
Umbraco Razor Feature WalkthroughâPart 7
However, when I try this code:
foreach (var id in networkitem.networkAssociatedMember)
{
DynamicNode member = new DynamicNode(id.InnerText);
if (member.IsLast())
{
@(member.Name);
}
else
{
@(member.Name + ", ");
}
}
This condition that checks if a DynamicNode is the last in the set is still passed, so that the outcome is rendered like this:
(associatedmember, associatedmember,)
while it should be
(associatedmember, associatedmember)
why is this not working?
thanks for your help,
Anthony
Hi Anthony,
Did you get this sorted ou ? Am having the same issue here
@Fuji, seems the IsLast() is the method to check if a dynamic is the last item in a collection. See also this post:
http://our.umbraco.org/forum/developers/razor/33671-Display-last-item-from-media-folder
greetings,
Anthony
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.