Search code examples
asp.netsql-server-2008c#-4.0imageurl

Why the Generated ImageUrl is wrong


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


Solution

  • 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);