locked
How to display an Image from a SQL link RRS feed

  • Question

  • User1130620715 posted

    Congratulations, first of all, on this new SP1, it adds immesurably to the richness of Framework 3.5!

    I have a database table with references to images (jpg's) such as media/images/img_2100.jpg.  (Columns look something like this MediaID, MediaCategory, MediaName (where the MediaName is the jpg address)).

    The product table refers to them.

     DynamicData automagically displays the correct string for the product.  How can I make it disply the corresponding image, instead?

    On the Edit page, I would like both the image and the path displayed, how would I do that? 

     

    Thanks,

     

    Paolo

     

    Thursday, August 28, 2008 9:10 AM

All replies

  • User472117617 posted

    use an <asp:Image/> control and bind the ImageUrl property to your data.

    Thursday, August 28, 2008 10:29 AM
  • User660823006 posted

    You can also look at the FileImage and DbImage field templates we have in the Dynamic Data Futures project: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14475

    Thursday, August 28, 2008 12:14 PM
  • User-330204900 posted

    Also have a look at my article Dynamic Data: Part 1 - FileImage_Edit FieldTemplate on my blog.

    Hope this helps [:D]

    Thursday, August 28, 2008 1:20 PM
  • User1130620715 posted

    I see that this is an earlier release than SP1 - can I somehow just take some bits out, and keep the rest of the patch?  Would it work wiht a shared server that "only" has SP1?

     

    Thanks

    Thursday, August 28, 2008 2:47 PM
  • User1641955678 posted

    Not sure what you mean.  The Futures bits on CodePlex work with the final Dynamic Data bits that are in SP1.  And I think Steve's sample does as well.

    David

    Thursday, August 28, 2008 4:20 PM
  • User-330204900 posted

    Yep my sample works fine with SP1 RTM [:D]

    Thursday, August 28, 2008 5:35 PM
  • User1130620715 posted

    Thanks, that is what I suspected, but I can not figure out where to put it, since there seems to be so much templating.  Could you tell me where one would make as <asp:Image/> tag appear (in what file)?  What I would ideally like to do is to add a column, so that one entry is the path from the database e.g. Images/Image1.jpg, and the other column would contain the image itself. 

     

    Thanks

    use an <asp:Image/> control and bind the ImageUrl property to your data.

    Tuesday, September 9, 2008 12:39 PM
  • User-330204900 posted

    Hi PaoloTCS, have a look at the followon article Dynamic Data: Part 2 - FileImage_Edit FieldTemplate which has a download of a sample website with the FileImage_Edit FieldTemplate in and working.

    Hope this helps [:D]

    Tuesday, September 9, 2008 7:38 PM
  • User1130620715 posted

    Hello again, and Thanks for all the help.

    I have been combing over your site, and it looks extremely useful.  I however only know VB.Net (sort of) so many of the examples are not as clear to me as I would like. 

    I tried to have an online service translate using the online DeveloperFusion tool C# to VB, but I get errors in Visual Studio.  In particular, when I translate your FilrImageAttributes.cs into VB, I get errors in

    Public Function ToString() As String

    Dim extensions As New StringBuilder()

    For Each ext As var In ImageTypes

    extensions.Append(ext + ", ")

    Next

    Return extensions.ToString().Substring(0, extensions.Length - 2)

    End Function

    -------------------

    The error I get is:

    "Type var is undifined" 

     

    in 2 places (the next one in the sub

    DisablePartialRenderingForUpload.

    Can anyone translate those parts?  (I used to be a simultaneous interpreter for the Fed Gov, and am sort of happy that machines still are not even remotely close to humans in translations, even sort of mechanistic ones like computer languages.)

    Thanks for all your help,

     

    Paolo

    Friday, September 12, 2008 9:38 AM
  • User-330204900 posted

    Hi give this a go The Labs \ Convert C# to VB.NET and convert the code to VB.Net [:D]

    Hope this helps [;)]

    Friday, September 12, 2008 9:47 AM
  • User1130620715 posted

    Yes, that is what I have been using.  It shows no errors in the conversion, but in VS 2008 it shows an error of "var not defined"

    Paolo

    Friday, September 12, 2008 11:40 AM
  • User-330204900 posted

    I think that that converter is not VB.Net 9 and c# 3.0 compat in VB.Net 9 a var equivalent is Dim

    i.e. Dim q = DC.Customer.SingleOrDefault() type of thing [:)]

    Have a look at this video VB9 - Anonymous Types

    Hope this helps [:D]

     

    Friday, September 12, 2008 1:50 PM