IhaveaMulti-Node Tree Picker andit is empty,this givesanerror.
foreach (var x in item.refKursus) { var n = @Model.NodeById(@x.InnerText); var nSta =@n.kursusStartDato.ToString("dd"); var nEnd = @n.slutDato.ToString("dd. MMMM yyyy"); <em class="date">@nSta<text>.</text> - @nEnd</em> }
Error loading Razor Script BlockHolding.cshtml Input string was not in a correct format.
What cansolve this?Iwilltryif elsebutnulland "" gives meanerror.
Error loading Razor Script BlockHolding.cshtml Operator '!=' cannot be applied to operands of type 'umbraco.MacroEngines.DynamicXml' and 'string
foreach (var x in item.refKursus) { var n = @Model.NodeById(@x.InnerText); var nSta =@n.kursusStartDato.ToString("dd"); var nEnd = @n.slutDato.ToString("dd. MMMM yyyy"); <em class="date">@nSta<text>.</text> - @nEnd</em> } }
Multi-Node Tree Picker if it is empty..
hey guys
I have a Multi-Node Tree Picker and it is empty, this gives an error.
Error loading Razor Script BlockHolding.cshtml
Input string was not in a correct format.
What can solve this? I will try if else but null and "" gives me an error.
Error loading Razor Script BlockHolding.cshtml
Operator '!=' cannot be applied to operands of type 'umbraco.MacroEngines.DynamicXml' and 'string
Many thanks
/Johan
Thank you Bert, it was just what was needed!
my code is now:
@if (@item.HasProperty("refKursus") && @item.GetProperty("refKursus").Value != String.Empty)
{
foreach (var x in item.refKursus)
{
var n = @Model.NodeById(@x.InnerText);
var nSta =@n.kursusStartDato.ToString("dd");
var nEnd = @n.slutDato.ToString("dd. MMMM yyyy");
<em class="date">@nSta<text>.</text> - @nEnd</em>
}
}
/Johan
Her's my 5 cents
Hope it will help some one (c:
is working on a reply...