Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends

i have database in which 3 fields ID , ImageName, ImagePath
datatype for ImageName and ImagePath is Nvarchar

i have created a global variable :-
C#
private Image _ProductImage;
 public Image ProductImage
    {
        get { return _ProductImage; }
        set { _ProductImage = value; }


    }
which returns image datatype

i have a imagecontrol in my aspx
in that image control i have to display image from database where in database only the path is defined in string
C#
Products prod = new Products();
prod.ProductImage = sdr["ImagePath"];
ImageItem.ImageUrl = Server.MapPath(prod.ProductImage);

some wrong in this code please figure it out friends.... URGENT
Posted
Updated 14-Nov-12 0:50am
v2

Hi Can you try without using Server.MapPath ? Using '~' in the beginning.

ImageItem.ImageUrl = "~/IMAGES/Test.ico";


Regards
Dominic
 
Share this answer
 
Comments
sreeCoderMan 14-Nov-12 7:12am    
actually i need to get varying images not a particular image
Dominic Abraham 14-Nov-12 7:26am    
Is the location of the image is outside your website?
You can refer the link
http://forums.asp.net/t/1608488.aspx/1
sreeCoderMan 14-Nov-12 7:33am    
no the images are in the same root ... in one folder named "images"
Dominic Abraham 14-Nov-12 7:39am    
if possible can you list some results (paths) assigning to
prod.ProductImage property when you are debugging.
sreeCoderMan 14-Nov-12 7:43am    
if i change the return value to string i will get the path value.. "G:\root\Images\634456168350187500s.JPG" but i need to convert this path to an image or i should get the image from folder using this path
friend i got it..... i will share with you...

i changed
C#
private Image _ProductImage; 
public Image ProductImage 
{ 
  get { return _ProductImage; } 
  set { _ProductImage = value; } 
}

to
C#
private string_ProductImage; 
public string ProductImage 
{
 get { return _ProductImage; } 
 set { _ProductImage = value; } 
} 

and created a
C#
private void showimage(string imagepath) 
{
 imagecontrol.ImageUrl = "~/foldername/" + imagepath +""; 
}

and called this

C#
prod.ProductImage = sdr["PImagePath"].ToString(); showimage(prod.productImage);


[edit]code block added[/edit]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900