Link to home
Start Free TrialLog in
Avatar of aquila98
aquila98

asked on

how to display image in a bounded grid (to access .mdb) on a web page ???

Hello

My problem is this:
I am using Dreamweaver 8 to build a pesonnal web site. I added a page that will display thumbnails and of course when you clic you get big picture. pretty standard so far...

But I do not want to read file. instead I want to just upload a access file and read from the database...

I have build a dome using a dataviewgrid in a C# project (.exe) with visual studio 2005 and I fugured I could do the same and re-use the same logic on a datagrid in a web page.

So I created a web site in visual studio 2005 and added a grid and a data source... but now I cannot get the bitmap field to be displayed in the grid cell! I see all the text but no images :(

Is there a simpler way? some control that binds to a ado or oledb available out there? Or is there a better way to do this? I figure uploading a .mdb file is much simpler that sending a bunch of .jpg files! But how to do this????

once the visual studio page is done I will simply add it to the dreamweaver site and it should work ;) but I need help being sucha newby at web stuff!!!

thanks
Avatar of Rouchie
Rouchie
Flag of United Kingdom of Great Britain and Northern Ireland image

The gridview contains a field called the ImageField.  DW probably won't know it exists because it does not support ASP.NET very well, and certainly not ASP.NET 2.0 whatsoever.

Within the gridview's <columns> tags, add this line:

  <asp:imagefield datafield="myDataBaseImageFieldName" headertext="Picture" />

Obviously substituting "myDataBaseImageFieldName" with the correct name from your database field.

Here's a site with a working C# example - http://authors.aspalliance.com/aspxtreme/sys/web/ui/webcontrols/demos/gridviewimagefield.aspx
Avatar of aquila98
aquila98

ASKER

exactly what I want...
except how can I get this to work thare is lots of stuff missing, where is this class fetchData_oledb.cs documented? I guess this is the data fetcher class from the access file... do you know where I can get a complete VS 2005 solution to better understand how the pieces work together?

but it is a great start, I'll try to integrate into my existing VS 2005 web site

thanks for the link
the datafield is not part of the asp:imagefield... i used DataImageUrlField instead... but does not seems to work :(
fetchData_oledb.cs will be the class that particular website is using to hide the database logic from readers.  Don't worry that - what's important is getting the ImageField created in the GridView, and pulling the data through into it.

If you've already got the database connection set up, just add the new gridview column and see what happens - ASP.NET should do the rest for you!
>> i used DataImageUrlField instead... but does not seems to work :(

Okay I see your confusion. Before I go on I should just make sure that the images themselves are not stored in the database, just the file names, correct?

If so, now you've specified the image's file name, you need to specify the path

<asp:imagefield dataimageurlfield="dataBaseFieldName"  dataimageurlformatstring="~\Images\{0}.jpg"  />
in fact, the image data is stored in the database file.
I have a VS2005 c# application that build the access database with the actual .jpg and a reduce thumbnail for each row of the database. Then I upload the .mdb filr to the web site and the page should display the thumbnail in a grid. When the user clic a thumbnail it display a detailview with the actual picture and metadata taken from the database. not url and no .jpg files are uploaded to the website...

Ahh okay, well then this approach won't work without modification.  I've not used your approach before, but I believe you need to create a sub that converts the raw data into an image.

You might have to Google the display of images from a database, but this page has a sample:

http://www.syncfusion.com/FAQ/aspnet/WEB_c27c.aspx#q567q
http://www.codeproject.com/cs/database/images2db.asp
first solution is close... but the grid would have to open a connection for each row and worse it savec the image to a file...

if there was a way to generate the urldynamically to fool the grid into thinking that the data is from a file but instead package it from a stream ...
something like http://getpicturedatafromdatabase.aspx?pictureidfromgrid then I could use the <asp:imagefield dataimageurlfield=...

have you seen such code anywhere?

I'll google, thanks for help!
No I haven't I'm afraid, and DW certainly won't help you.  You really need to be using VS2005 (I use the free Web Developer version).

You could try posting a link in the ASP.NET topic area.  I'm sure one of those Experts will know how to solve it.
Ah sorry I didn't realise you had cross-posted.  I'm sure someone will help soon enough... :-)
I have found a working solution...
I build a webcontrol using a sample provided by msdn (wickedcode056) and I converted the field in the grid to a template. Then I edited the template and replaced the label control with a webcontrol to display the image and behold it worked!

thanks anyway for your hints.
ASKER CERTIFIED SOLUTION
Avatar of kodiakbear
kodiakbear

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial