you are never binding the information anywhere? by calling the function, you should have bound your information to your datagrid. That's what you're missing.
SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
Well for one, it was stupid to put it that way unless you are going to change the page's name a lot. Instead of using a function, just place this:
ImageUrl='readrealimage.aspx?id=<%# DataBinder.Eval(Container.DataItem, "PersonID") %>
Why makea function that just add's static text? anyway.. :)
Make sure you have more than one record in the database, and that you have different photos with different ID's. Which I am sure you do.
I am not sure exactly why you're doing it this way.. personally I think you should set up a image resize function that saves the image to a folder with the id of your Person. Then just call it on the page like you were. Where are your images, in a database?
SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
Well, try to avoid saving images to a database, as it eats up reasources trying to display them and is very slow. Anyway, if you name the images something easy like the Person's ID or something, then you can just reference it in by using
.jpg" />
This just puts out the person's id. If you person's id is 2123 and your photo id is 2123, then by just spitting out the person's id, you will reference in the photo. If you would like a resizing function for your uploaded photos, just let me know. When a user will upload their photo, the resizing function will be called and saved to a location that you choose with the appropriate name. Then when you call it from another page, just put the path in the img src with the reference to the person's id. That way it will automatically be spit out and you have nothing to worry about database wise except for the users info.
SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
'' resize uploaded pictures into thumbnails.
Function generateThumbnail(ByVal newWidth As Integer, ByVal strFileName As String)
Dim bmp as Bitmap
Dim newHeight as Integer
Dim resized as Bitmap
Dim filePath As String = Server.MapPath("/")
'now Server.MapPath("/") just points to your root. Find your folder that you wish to save to
'Much like "www.domain.com/users/images/" -> Server.MapPath("/users/images/")
bmp = System.Drawing.Image.FromFile(filePath & "TEMP_" & strFileName)
newHeight = (newWidth/bmp.width)*bmp.Height
resized = new Bitmap(newWidth,newHeight)
Dim g as Graphics = Graphics.FromImage(resized)
g.SmoothingMode = SmoothingMode.HighQuality
g.CompositingQuality = CompositingQuality.HighQuality
g.InterpolationMode = InterpolationMode.High
g.DrawImage(bmp, new Rectangle(0,0,resized.Width,resized.Height),0,0,bmp.Width,bmp.Height,GraphicsUnit.Pixel)
g.Dispose()
resized.Save((filePath & strFileName),ImageFormat.Jpeg)
bmp.dispose()
if File.Exists(filePath & "TEMP_" & strFileName) then File.delete(filePath & "TEMP_" & strFileName)
End Function
Now this code uses two values for you. A size for the width of the thumbnail you wish and the id you wish to name the thumbnail, which this should be your PersonID or UserID. Now keep in mind, this ONLY TAKES JPEG images. It will not work with a gif, png, or the like. It must be jpeg or you will have an error.
To use the above function, you need to grab your uploaded file and save it to your directory as"TEMP_" & PersonID. After you saved it, call the generateThumbnail(sizeyouwishinpixels, PersonID). After you call this function, it will delete your TEMP picture.
Now your picture has been resized and saved with your PersonID. Now to call this, just put it down like the following:
<img src="/FilePathYouChoseInResizeFunction/<%# DataBinder.Eval(Container.DataItem, "PersonID") %>.jpg" alt="" />
SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68