Click here to Skip to main content
15,886,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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...

XML
<asp:imagebutton id="ImageButton1" imageurl="<%# Eval(" picture=") %>" commandname="Image" xmlns:asp="#unknown" />
Posted
Updated 26-Aug-10 0:32am
v3
Comments
GPUToaster™ 23-Aug-10 2:18am    
use http handlers for specific urls!!

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[^]
 
Share this answer
 
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.
 
Share this answer
 
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")%&gt;"="" width="100px" height="100px" xmlns:asp="#unknown">;
 
Share this answer
 
Comments
Christian Graus 26-Aug-10 4:10am    
What on earth is the point of saying this when someone else has already given an extensive answer ?

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