Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
I am using FileUpload control, after submit of uploadclick button..the file name is saved in database.. and then I am reteriveing it in gridview ... where I bind image button?
 

Problem is that SubmitQuery is display instead of image plz help...
 
<asp:imagebutton id="ImageButton1" imageurl="<%# Eval(" picture=") %>" commandname="Image" xmlns:asp="#unknown" />
Posted 22-Aug-10 19:44pm
balongi1.1K
Edited 26-Aug-10 1:32am
v3
Comments
GPUToaster at 23-Aug-10 2:18am
   
use http handlers for specific urls!!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I am not sure whether I understood your problem correctly. Assuming that you have the following situation:
 
1. You are uploading the file successfully using the FileUpload control.
2. You are able to save file data into database (Say, file name, size etc)
 
Now while you are trying to display the image button in the Grid View, you are trying to show the images as the Image button's background. But, for some reason, the image is not being shown for the image buttons.
 
If the above understanding is correct, here is what you need to work on:
 
An important issue is, where are you storing the file content. In the database? Or, in the file system.
 
Assumption1 : File content is stored the file system
 

--If you are storing the file content in the file system, then, either in the "picture" property of your object should have a correct URL value that points to the image within the web application folder, or, you should use a method that takes the "picture" property value as parameter and returns the relative URL of the image.
 
For example, suppose you storing the image "profile.jpg" as "/images/profile.jpg" within the web application folder. so, either the "picture" property of your object should contain the URL "~/images/profile.jpg" or you can call a method GetImageUrl() as follows:
 
Imageurl="<%# GetImageUrl(Eval ("picture")) %>"
 
where the method willl take just the "profile.jpg" as parameter and will return "~/images/profile.jpg"
 
Good luck
 
Assumption2 : File content is stored in the database
 

--Well, in this case, you have to do a bit more work. You have to provide the ImageUrl property value as described above and then you have to create an HttpHandler that would handle any URL that has image file extension in the request file name and read and writes the file content in the output stream.
 
See an example HttpHandler here : http://kurtschindler.net/blog/Post/Using-HttpHandlers-to-serve-image-files[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

you can add image folder in solution explorer.. with implementing server.map math function in code behind class..
 
after that :
 
<asp:imagebutton id="ImageButton1" runat="server" imageurl="<%# "~/images/" + Eval("picture")%>" width="100px" height="100px" xmlns:asp="#unknown" />;
  Permalink  
Comments
Christian Graus at 26-Aug-10 4:10am
   
What on earth is the point of saying this when someone else has already given an extensive answer ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Dear,
you have to add temporary folder in your solution and on RowDataBound Event you have to get byte[] data which could be stored in HiddenField like
 
 <asp:hiddenfield id="hdfData" value="<%# Eval("ImageData")%>" xmlns:asp="#unknown" />
 
which is in gridview itemtemplate and retrieve in _RowDataBound Function.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 195
3 DamithSL 195
4 Richard MacCutchan 178
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 12 Oct 2011
Copyright © CodeProject, 1999-2014
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