Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 21st, 2004, 06:42 PM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Bind image to the datagrid

I have a column Image in the table, data type varchar which hold the path to the actual image in my computer eg :- C:\Images\book.jpg.
When I try to display the result in the datagrid in web application it displays the path to me as C:\Images\book.jpg.
What I actually want is the actual picture instead of the full path.
I tried this code too:-
string img ="";
foreach(DataRow row in imageDataSet1.Tables["ImageTable"].Rows)
{
   img =row[0].ToString();
   //labISBN.Text = row[1].ToString();
   //labTitle.Text = row[2].ToString();
}
If I say Image1.ImageUrl = img;

I can get the image but not in the data grid
If I say DataGrid1.DataBind();//other code omitted
It displays the full path not the actual image in that column
I couldn’t find options in the property builder of the datagrid
I’m using C# as the programming language.
Please suggest me with few lines of code.
Thanks in advance,
Reply With Quote
  #2 (permalink)  
Old October 31st, 2004, 09:44 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Dear friend: (Im back)
ensure u have created a Virtial Directory fot ur site so u should have that Addr. & for that u shoul dur
Code:
Server.MapPath("C:\\Images\\book.jpg");
Keep in touch.

Always:),
Hovik Melkomian.
Reply With Quote
  #3 (permalink)  
Old October 31st, 2004, 05:00 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I don't think this will work, Melvik. Server.MapPath works the other way around as it accepts a virtual path (like /Databases/Database.mdb) and will return a physical location like C:\MySite\Databases\Database.mdb)

learner_7983: You have a bit of a problem here; On your local machine, C:\Images\Image1.jpg will work, but not anywhere else.
To allow the browser to download a file, you'll need to reference it with a path that can be reached from within the site (e.g. /Images, like http://localhost/Images or www.YourServer.Com/Images

I think the easiest fix is to create a virtual folder under IIS called Images that points to C:\ImagesNext, in your databinding expression, take the full path and extract the file name. That is, make sure you get book.jpg from a path like C:\Images\book.jpg.

Then in your Image, set the path to:

ImageUrl = "/Images/" + imageFileName;

Alternatively, and better, store the root relative path in the database; just storing /Images/book.jpg or even book.jpg allows for a flexible setup.....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #4 (permalink)  
Old November 1st, 2004, 02:00 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

But I thought he can not accecc the image location in localhost.

Always:),
Hovik Melkomian.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Bind Data in DataGrid akumarp2p C# 2005 2 December 30th, 2006 12:11 PM
Datagrid Bind Problem param99 ASP.NET 1.0 and 1.1 Professional 1 November 23rd, 2006 12:34 PM
can we bind datagrid and dropdown list rakeshgv SQL Server 2000 0 August 21st, 2006 02:13 AM
bind a image filename stored in DB wth FORMSVIEW alexdcosta ASP.NET 2.0 Basics 0 June 22nd, 2006 05:30 AM
Bind datagrid to recordset MAntis_sg Classic ASP Databases 0 May 15th, 2006 07:31 AM



All times are GMT -4. The time now is 11:10 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.