Solved

gridview display image

Posted on 2012-04-11
4
229 Views
Last Modified: 2012-06-21
Have programtically (intentionally) set up a gridview to display data from an XML dataset. Works fine expect when trying to display images in a column using following technique:

        dcol = New DataColumn("AnImage", GetType(ImageField))
        dcol = New DataColumn("AnImageURL", GetType(String))

        drow("AnImage") = New ImageField
        drow("AnImage").DataImageUrlField = "AnImageURL"

        drow("AnImageURL") = "image/picture.jpg"

Column just displays "ImageField". Any thoughts please ?
0
Comment
Question by:cehrnow
  • 2
  • 2
4 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37834006
add a templatefield to your gridview columns.
In this template field add HtmlImage and assign its src the image path.
0
 

Author Comment

by:cehrnow
ID: 37834119
Thanks. Any chance you could show the code ?
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37834215
suggest you read this article:-

http://msdn.microsoft.com/en-us/magazine/cc301573.aspx

It tells you how to create a template field programatically.

This one as well:-
http://msdn.microsoft.com/en-us/library/system.web.ui.itemplate%28v=vs.71%29.aspx

BTW i would never try doing this as its much simpler and easy to declare a template field in markup and then control the markup from code behind. You have tons of events that you can handle to have full control on what kind of data, what style and what behavior you want to add to your gridview. Its good for learning, but hardly i ever see it getting used in production....
0
 

Author Closing Comment

by:cehrnow
ID: 37835201
I see what you mean. Now reluctantly decided to use bound fields setup within design mode.
Thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now