locked
i hav d same doubt....:( RRS feed

  • Question

  • Does anyone know how to attach hyperlinks to images dragged dynamically into GridView from a MS Access database? I can use an ImageField to display the images, but that doesn't appear to have a hyperlink property. Conversely, I can use hyperlinkfield to create hyperlinks, but can't get that to display the images. Is there any way of combining the two in order to get hyperlinked images where both the hyperlink and the image are dynamic? I have done some scouting on the net and there appears to be a solution using templatefield and adding some code (using ImageUrl), but I can only get this to display static content. Any help much appreciated. Apologies for any lack of clarity in this question, I've only been experimenting with ASP.NET for a day or so.
    Friday, May 17, 2013 7:41 AM

All replies

  • Sure you can do it.  But first please clarify what you mean by "images dragged dynamically into GridView from a MS Access database".  There is no dragging involved in displaying images from database information.  There are also more ways than one to store image information in a database: how are you storing yours?  As an actual image (hope not - that gets complicated) or as a file name from which you can construct the image URL?  And where do you get the information for the link you want to associate with the image?  Is that fixed?  Or created from information from the database?

    The solution will be one of several variations, all of which involve evaluating the information from the database and formatting it as an attribute of one or two controls.  For example, a HyperLink control has both a NavigateURL attribute and an ImageURL attribute, so that could be one control to handle both.  The HyperLinkField in GridView doesn't have the ImageURL, but if you put a HyperLinkField in your GridView, then "Convert to Templated Field", you'll end up with a HyperLink control you can edit in Code View to add the ImageURL.

    See an example: http://social.msdn.microsoft.com/Forums/en-US/web/thread/2cfb1c05-5755-4404-9c6b-e6935cbac4a3/


    • Edited by KathyW2 Friday, May 17, 2013 2:41 PM
    Friday, May 17, 2013 1:04 PM