Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 28th, 2004, 10:50 PM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display a photo in a DataGrid

Hi,

I want to display photos in a DataGrid column. I receive the filename of the photos in an XML file along with other data which I have no problem doing.

I read the XML into a DataSet. I then create another DataSet (bound to my DataGrid) along with a DataTable and DataRow. I load the data from the 1st DataSet into the rows of the bound DataSet, but I am having trouble getting the photo displayed in my DataGrid.

I have tried code like:

objRow.Item(4) = Image.FromFile("photo_01.jpeg")

and other variations and still can't get it to work.

Can I display photos in a DataSet bound to a DataGrid?

How can I do this?

My problem would be solved if I could include the photos in my XML file which can't be done.

Thanks


Kerry O'Carroll
__________________
Kerry O\'Carroll
 
Old December 29th, 2004, 09:52 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Check whether this would help ::

1. http://www.dotnet247.com/247reference/msgs/5/26214.aspx
2. http://www.google.com/search?hl=en&l...es+in+DataGrid

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old December 30th, 2004, 01:42 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Vadivel,

Thanks for the links. I have been looking through them and some make reference to 'DataGridImageColumn' class yet I cannot find that class in my .Net Framework under the Help.

I am using the .Net Framework version 1.1 - Visual Basic

Do I need to use 'DataGridImageColumn' to display images in my DataGrid on my WebForm.

Thanks


Kerry O'Carroll
 
Old December 30th, 2004, 01:45 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just a thought,

do I have to import any Namespaces eg "imports system.drawing.images"

Kerry O'Carroll
 
Old December 30th, 2004, 05:43 AM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Here is some of the code I have used:

This is how I created my Columns:

Dim objDT As DataTable
Dim objRow As DataRow

Dim colOverview As New DataColumn
colOverview.ColumnName = "Overview"
colOverview.DataType = GetType(String)
objDT.Columns.Add(colOverview)

Dim colPhoto As New DataColumn
colPhoto.ColumnName = "Photo"
objDT.Columns.Add(colPhoto)

Here is some more code (note that the image filename is in strPhoto):

' Create a new row

objRow = objDT.NewRow()

' Add data to the row

objRow.Item(0) = strLocation

objRow.Item(1) = Image.FromFile(Server.MapPath(".") & "\xml\" & strPhoto)

' Add row to the DataTable

objDT.Rows.Add(objRow)

This is the code where I bind the DataTable to the DataGrid:

' Bind the DataTable to the DataGrid

With objDG
.Visible = True
.DataSource = New DataView(objDT)
.DataBind()
End With

Kerry O'Carroll





Similar Threads
Thread Thread Starter Forum Replies Last Post
VB Display Photo using URL from Database Rich57 ASP.NET 2.0 Basics 2 May 30th, 2008 05:31 AM
Error posting photo to photo album abel714 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 10 February 5th, 2007 03:07 AM
Datagrid display Lovehead VB.NET 2002/2003 Basics 1 January 20th, 2007 05:12 PM
Display 'no photo' in a JSP when photo is not pres Inderjeet Pro JSP 0 April 21st, 2006 05:35 AM
fading from photo to photo in flash elladi Flash (all versions) 1 November 28th, 2004 11:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.