Solved

gridview display image

Posted on 2012-04-11
4
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

632 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