Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

gridview display image

Posted on 2012-04-11
4
Medium Priority
?
296 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

877 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