gridview display image

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 ?
cehrnowAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
BuggyCoderConnect With a Mentor Commented:
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
 
BuggyCoderCommented:
add a templatefield to your gridview columns.
In this template field add HtmlImage and assign its src the image path.
0
 
cehrnowAuthor Commented:
Thanks. Any chance you could show the code ?
0
 
cehrnowAuthor Commented:
I see what you mean. Now reluctantly decided to use bound fields setup within design mode.
Thanks
0
All Courses

From novice to tech pro — start learning today.