Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 :-
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
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 14-Nov-12 1:36am
Edited 14-Nov-12 1:50am
member6016.1K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi
Can you try without using Server.MapPath ? Using '~' in the beginning.
 
ImageItem.ImageUrl = "~/IMAGES/Test.ico";
 

Regards
Dominic
  Permalink  
Comments
sreerajsn123 at 14-Nov-12 7:12am
   
actually i need to get varying images not a particular image
dominicthoppil at 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
sreerajsn123 at 14-Nov-12 7:33am
   
no the images are in the same root ... in one folder named "images"
dominicthoppil at 14-Nov-12 7:39am
   
if possible can you list some results (paths) assigning to
prod.ProductImage property when you are debugging.
sreerajsn123 at 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
sreerajsn123 at 14-Nov-12 7:58am
   
friend i got it..... i will share with you...
 
i changed private Image _ProductImage;
public Image ProductImage
{
get { return _ProductImage; }
set { _ProductImage = value; }

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

 
}
 
and created a
 
private void showimage(string imagepath)
{
imagecontrol.ImageUrl = "~/foldername/" + imagepath +"";
}
 
and called this
prod.ProductImage = sdr["PImagePath"].ToString();
showimage(prod.productImage);
sreerajsn123 at 14-Nov-12 8:13am
   
thankyu dominicthoppil for your help
dominicthoppil at 14-Nov-12 8:24am
   
very good :-)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

friend i got it..... i will share with you...
 
i changed
private Image _ProductImage; 
public Image ProductImage 
{ 
  get { return _ProductImage; } 
  set { _ProductImage = value; } 
}
to
private string_ProductImage; 
public string ProductImage 
{
 get { return _ProductImage; } 
 set { _ProductImage = value; } 
} 
and created a
private void showimage(string imagepath) 
{
 imagecontrol.ImageUrl = "~/foldername/" + imagepath +""; 
}
and called this
 
prod.ProductImage = sdr["PImagePath"].ToString(); showimage(prod.productImage);
 
[edit]code block added[/edit]
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 650
1 Maciej Los 525
2 Suvendu Shekhar Giri 229
3 Sascha Lefévre 229
4 Richard Deeming 195
0 Sergey Alexandrovich Kryukov 9,693
1 OriginalGriff 9,185
2 Peter Leow 5,112
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,876


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100