0

That is the code to get url of image from the folder

 <asp:Repeater ID="rptImages" runat="server">
    <ItemTemplate>
        <li>
            <img alt="" style='height: 75px; width: 75px' src='<%# Eval("Images") %>' />

        </li>
    </ItemTemplate>
</asp:Repeater>

This do display images

string[] filesindirectory = Directory.GetFiles(Server.MapPath("~/Images"));
List<String> images = new List<string>(filesindirectory.Count());

foreach (string item in filesindirectory)
{
    images.Add(String.Format("~/Images/{0}", System.IO.Path.GetFileName(item)));
}

rptImages.DataSource = images;
rptImages.DataBind();

when i run it it says:" An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. "

and show :( List<String> images = new List<string>(filesindirectory.Count());) in red

What should i do?

Sagar
  • 454
  • 10
  • 22
Naeem
  • 11
  • 8

1 Answers1

0

I have not encountered error you mentioned, but I found another error on the binding.

Here you should change the binding using Container.DataItem and since you are using ~ for the path you should add runat="server" like mentioned in this link.

<img alt="" style='height: 75px; width: 75px' src='<%# Container.DataItem %>' runat="server"/>
Community
  • 1
  • 1
robby
  • 1
  • 2
  • The same Error. That is Error Message: CS0246: The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?) – Naeem Sep 23 '16 at 20:04