Anyone can tell what is wrong here ? I cant convert to Int64 and my cshtml file keeps giving me an ugly error message.
int Id = Convert.ToInt32(library.GetDictionaryItem("as"));
var folder = new Media(Id);
IEnumerable<Media> fd = folder.GetChildMedia();
<div class="docCn-">
<div id="docMnu-">
<ul>
@foreach(var p in fd){
@foreach(var p in fd){
var bytes = Convert.ToInt64(@p.getProperty("umbracoBytes").Value);
}
</ul>
</div>
</div>
Converting to Int64 Failed
Anyone can tell what is wrong here ? I cant convert to Int64 and my cshtml file keeps giving me an ugly error message.
int Id = Convert.ToInt32(library.GetDictionaryItem("as")); var folder = new Media(Id); IEnumerable<Media> fd = folder.GetChildMedia(); <div class="docCn-"> <div id="docMnu-"> <ul> @foreach(var p in fd){ @foreach(var p in fd){ var bytes = Convert.ToInt64(@p.getProperty("umbracoBytes").Value); } </ul> </div> </div>Hi Fujl,
Is it meant that you should have two foreach loops or should you only have one like this:
int Id = Convert.ToInt32(library.GetDictionaryItem("as"));
var folder = new Media(Id);
IEnumerable<Media> fd = folder.GetChildMedia();
<div class="docCn-">
<div id="docMnu-">
<ul>
@foreach(var p in fd){
var bytes = Convert.ToInt64(@p.getProperty("umbracoBytes").Value);
}
</ul>
</div>
</div>
/Dennis
Dennis i just happened to notice that some of the Media Items dont have any file attached to it and so fails.
@if(p.getProperty("umbracoBytes").Value != String.Empty){ var bytes = Convert.ToInt64(@p.getProperty("umbracoBytes").Value); var x = ((Math.Round(Convert.ToDecimal(@bytes) / 1048576, 1)).ToString() + "MB"); var y = ((Math.Round(Convert.ToDecimal(@bytes) / 1024, 1)).ToString() + "KB"); var z = (bytes>= 1048576)? x:y; <a href="@p.getProperty("newsUpload").Value" target='_blank'> Download File <span class="sizedoc"> { @z }</span> </a> }You should really use Int64.TryParse It wont throw an execption :) Charlie
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.