Solved

gridview display image

Posted on 2012-04-11
4
245 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 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