Must give imageurl like this
DataSet ds1 = new ClientProductView().GetMainPhotoInDeatailPage(1);
string img = ds1.Tables[0].Rows[0]["MainPhoto"].ToString();
image.ImageUrl = string.Format("productimages/main/" + img);
Domanda
i have strored images in a folder within my project with name like this
(ProductID).Extention
and other details of image are stored in the database
i have used the following procedure to fetch the image
create proc prcMainPhoto(@ProductID int)
as
select p.ProductID ,
isnull(( select top 1 convert(varchar,PhotoID,10) + '.' + ExtName from ProductPhoto where ProductID= p.ProductID ),'NoImage.jpg')as MainPhoto
from ProductInfo as p where p.ProductID=@ProductID
and give imageurl to image like this
DataSet ds1 = new ClientProductView().GetMainPhotoInDeatailPage(productid);
string img = ds1.Tables[0].Rows[0]["MainPhoto"].ToString();
imgmain.ImageUrl ="./productimages / main / "+ img;
but the image is genrating this url
http://localhost:1030/SShopping%20Website/ProductDetails.aspx?ProductID=1#
i have coded in page ProductDetails which is placed outside
Please help
Soluzione
Must give imageurl like this
DataSet ds1 = new ClientProductView().GetMainPhotoInDeatailPage(1);
string img = ds1.Tables[0].Rows[0]["MainPhoto"].ToString();
image.ImageUrl = string.Format("productimages/main/" + img);
Altri suggerimenti
I think that the issue here is that ImageUrl can only be assigned with either a relative or an absolute URL. I think that the use of . in your URL path is that is causing the issue.
Try setting the image url with a relative path:
imgmain.ImageUrl ="~/productimages/main/" + img;