By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,602 Members | 1,553 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,602 IT Pros & Developers. It's quick & easy.

Using GridView event to display image in GridView in IMAGE control

P: 3
Hi All,

1. My colleague and Me have created a small application, we are storing some data & images using this application. The destination path for this images is the " application startup path" + the Image folder, which we created in the application folder.

The file path will be like "C:\Documents and Settings\suresh\Desktop\RegIR_NEW\RegIR\bin\Debug\ ..\..\Images\8-Q-IMG.jpg".

where "C:\Documents and Settings\suresh\Desktop\RegIR_NEW\RegIR\bin\Debug" is the " application startup path" and "\..\..\Images\8-Q-IMG.jpg" is the image folder name and the image name.

The image is stored in "Images folder" and the file path will be stored in Database.

2. I need to create an web application where I can retrieve the data from the database. on the click of a button I can able to retrieve the table from databse in Gridview.

What I want now is on the click of "SELECT Event or by any other event in gridview", I must get the corresponding image in that row in "Image Control"

Since in Gridview the image is in filepath I do not know how to display the image.

Can any one please please help on this?. If you have any doubt please let me know.

NOTE: I have uploaded the gridview screen shot.
Attached Images
File Type: jpg Gridview.jpg (15.3 KB, 213 views)
Dec 2 '13 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 5K+
P: 9,731
I am not sure what you are having problems with.

You created a VB.NET application (of unknown type) that copies or moves image files into the application's startup-path/images folder and you are recording the path to this image into a database.

This application doesn't seem to be causing you any problems but I have no idea what type of application this is or where this application is running.

Now you want to make a new ASP.NET application and you seem to be having problems with it...

Is your problem that:
  1. You don't know how to handle an event raised by a button in a GridView?
  2. You don't know how to display the images in the web browser?
    • Before we can help you with this we need to know: Is this application run on a computer that is NOT the web server?

Dec 2 '13 #2

P: 3
Hi Frinny,

Thanks for your reply.
I am using both of these application on remote server, by using "MSTSC". My main doubt is

1.whether I can get the image from gridview in a "Image" control, by using this kind of file path

"C:\Documents and Settings\suresh\Desktop\RegIR_NEW\RegIR\bin\Debug\ ..\..\Images\8-Q-IMG.jpg".

The above file path is in the application

2.If not can you please specify other method also by which I can get the image by using this filepath.

I am new to And your help will be great to me.

Thanks in Advance.
Dec 5 '13 #3

Expert Mod 5K+
P: 9,731
In your image that you posted, there is no "image control" being used. You have a column displaying text...which so happens to be a path that is stored in your database.

If your "desktop" application (I'm assuming it's a desktop application) stores, into the database, a path to the image on the computer that it is running on...and that application is run on a computer that is not the web-server... than how do you expect the web-server-code to ever get the image?

If the image does not exist on the web server, you cannot retrieve it in your code.

If the image does exist on the web server but in a place that is not accessible to the web browser, the image will not be displayed.

You cannot access the client's computer from server-side code. Likewise, you cannot access the client's computer files from JavaScript because of security concerns.

Let's pretend it's a perfect world and the image exists at the path in the database on the web server.

You should implement a method the GridView's OnSelectedIndexChanged Method.

In that method you should be able to retrieve the row that is selected, and then use the FindControl method on the row to retrieve the control that is displaying the path to the image.

Dec 9 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.