-1

My problem is that I just can't seem to get the actual file of my mapPath in my foreeach loop.

foreach (DataRow item in objKat.getProd().Rows)
    {
        ddlImage.Items.Add(new ListItem(Server.MapPath("../img/produkter/"), item["fldId"].ToString()));
    }

The actual problem is that I don't know what to write after produkter/". Hope any of you can help me. Thank you in advance! :)

3 Answers3

1

When you using the MapPath your path may look look this

 Server.MapPath("~/img/produkter/")

Read more about ASP.NET Web Project Paths

huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
0

IS Produkter is a Subfolder in img folder. If it's then your image name is in item["fldId"].ToString() then use that..otherwise your Relative path of image should be come after Produkter

Mayank Pathak
  • 3,621
  • 5
  • 39
  • 67
0

You need to escape the strings. If you want to go to /somefolder/fileyoudesire.ext, it needs to be //somefolder//fileyoudesire.ext

rainhider
  • 49
  • 1
  • 4
  • 13