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! :)
When you using the MapPath
your path may look look this
Server.MapPath("~/img/produkter/")
Read more about ASP.NET Web Project Paths
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
You need to escape the strings. If you want to go to /somefolder/fileyoudesire.ext, it needs to be //somefolder//fileyoudesire.ext
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.