Display File Size In Transformation

uzair Ahmed asked on April 23, 2018 13:35

Hello Team, i am Doing this to get File size in transformation.

< script runat="server" >

string sizeInKb;

protected override void OnInit(EventArgs e) {

CMS.DocumentEngine.AttachmentInfo ai = CMS.DocumentEngine.AttachmentInfoProvider.GetAttachmentInfo(ValidationHelper.GetGuid(Eval("FileAttachment").ToString(), Guid.Empty), CMS.SiteProvider.SiteContext.CurrentSiteName); sizeInKb = string.Format("{0:n1} KB", ai.AttachmentSize/ 1024f);

}

<%#Eval("FileName")%> (<%#sizeInKb%>)

But i am getting this error "[Error loading the control 'Repeater', check event log for more details] "

Correct Answer

David te Kloese answered on April 23, 2018 14:23

Well looking at your screenshot it looks like you're using the wrong field in your code..

Change the code in your first comment and update

Eval("FileAttachment")

to:

Eval("FileUpload")

0 votesVote for this answer Unmark Correct answer

Recent Answers


David te Kloese answered on April 23, 2018 13:43

Did you "check the event log for more details"? it might gave a null pointer for some repeated items not having an attachment or something like that.

1 votesVote for this answer Mark as a Correct answer

uzair Ahmed answered on April 23, 2018 13:53

Kindly direct me to right way, tell what i exactly have to do... i am confused

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on April 23, 2018 13:58

In the Kentico Administration interface go to the Event Log application and find the error.

Image Text

0 votesVote for this answer Mark as a Correct answer

uzair Ahmed answered on April 23, 2018 14:15 (last edited on April 23, 2018 14:15)

Ohh yes its Null exception, But then what is the way to file size of the attachment ,Image Text

kindly tell me the whole procedure i ll be very thankful!

Screenshot https://ibb.co/fCjAeH

0 votesVote for this answer Mark as a Correct answer

uzair Ahmed answered on April 23, 2018 14:49

ohh my Bad.. thankyou for help sir. :)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.