Try our conversational search powered by Generative AI!

List PageFiles for each page in a PageList


I would very much appreciate any ideas on how to show a list of PageFiles for each page in a PageList.



Jun 20, 2012 13:46

You could add a ItemDataBound event and then check the pagefiles for each item and list them if you so wish.


Jun 20, 2012 14:34

Thanks Petter.

Tried to download the source code for the original project for your link, but it seems that this was removed.

Being av newbie I found this a bit over my head and solved the problem in a less elegant way...


Jun 22, 2012 8:15

The good old <%#GetListOfFiles(Container.CurrentPage)%> ?

Jun 22, 2012 9:04

Hi Anders.

This would be very nice and simple, but GetListOfFiles does not exist inside the ItemTemplate of the PageList - At least not here...

Any suggestions?


Jun 22, 2012 9:12

Hi Anders.

My previous answer really place me as an EPiServer developer...

At first glance, I thought that you came up with an EPiServer solution to a known problem...

But I think that you are implying that I need to write my own method (GetListOfFiles).

If I should do this, I would like to display the files in a list with the filename as a hyperlink, the time it was uploaded, and the name of the user that uploaded. How would you solve this as opposed to write a method that returns a string to be diplayed inside a lebel control?


Jun 22, 2012 11:16


You are correct. I meant that you had to make the method yourself, or use this as a base:

public string GetListOfPageFiles(PageData page)


    string result = "";

    var dir = page.GetPageDirectory(false);

    if (dir != null)


        foreach (var fil in dir.GetFiles())


            string name = fil.Name;

            if (fil.Summary != null && !string.IsNullOrEmpty(fil.Summary.Title))

               name = fil.Summary.Title;

            result += "<li><a href=\"" + fil.VirtualPath + "\">" + name + "</a></li>";



    if (result != "")

        result= "<ul>" + result + "</ul>";

    return result;




Edited, Jun 22, 2012 11:50

The fil.Summary attributes gives you some data about the fil, and the fil object have some others

Jun 22, 2012 11:51

That's great Anders.

I have been working with EPiServer/ for 6 months now with no prior experience what so ever with c#/Visual Studio (I've worked with Delphi the last 10 years).

What I find the most frustrating with is that there are sooo many ways to solve a given task....

Thanks for the help - this will solve the task, and I will probably understand the code some time in the future.

Edited, Jun 22, 2012 13:05
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.