Displaying a jpeg file in a RadGrid

Thread is closed for posting
9 posts, 0 answers
  1. Steve Stilwell
    Steve Stilwell avatar
    4 posts
    Member since:
    Oct 2009

    Posted 19 Oct 2009 Link to this post

    I downloaded the trial version of the ASP.NET controls to see if they would work for a project I am about to start.  What I need to do is to display a date, some text, and an image about the text from a jpg file.  Our database contails a column with the name of the jpg (e.g., image1.jpg).  In the Gridview I was able to set it up to display the photo but I have not been able to figure out how to configure the RadGrid control to display the jpeg.  Any suggestions?

    Thanks.

    - Steve
  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 20 Oct 2009 Link to this post

    Hello Steve,

    In order to achieve the desired functionality I suggest you review the following online demo:
    Binary Images and Upload in Grid
    This example illustrates the usage of built-in GridBinaryImageColumn and how to display and edit images in it.

    I hope this helps.

    Kind regards,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Steve Stilwell
    Steve Stilwell avatar
    4 posts
    Member since:
    Oct 2009

    Posted 20 Oct 2009 Link to this post

    Thanks Pavlina.

    I think that means of displaying the photo is a bit different from what we had hoped to do.  We would prefer not to load the photo into the database but rather just have the database point to the jpeg file.  I was able to do that in Gridview.  Would I also be able to do that with RadGrid or some other Grid control (we need to display hierarcial data in the grid so I was thinking I would need the RadGrid).

    Thanks again.

    - Steve
  5. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 20 Oct 2009 Link to this post

    Hello Steve,

    Thank you for the clarification. For this purpose you can use the built-in GridImageColumn presented on this online demo of the product:

    http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx

    It is equivalent to the ImageField in the standard MS GridView control.

    Best regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Steve Stilwell
    Steve Stilwell avatar
    4 posts
    Member since:
    Oct 2009

    Posted 20 Oct 2009 Link to this post

    Thanks.  That seems to be getting things a little closer.  I now have something like this in my ASP page:

     

    <telerik:GridImageColumn DataType="System.String" HeaderText="ImageLocation" DataImageUrlFields="ImageLocation"

     

     

    ImageAlign="Middle" ImageHeight="100"

     

     

    DataImageUrlFormatString="~/{0}.jpg" UniqueName="ImageLocation">

     

     

    </telerik:GridImageColumn>

     

    For the first record the value in ImageLocation is:
        ~/guyser_DSC0069.jpg

    Which is the name of a jpeg file in the root of the web.  I added the column with the ImageLocation as just a string column so I can see it is getting it ok, but in the GridImageColumn i just a box where the image would go but no image.  There is also a smaller box in the box with a red X in it.  Any suggestion on what I need to do to get the image to display?

    Thanks again.
  7. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 21 Oct 2009 Link to this post

    Hello Steve,

    It seems that the images paths are not resolved properly in your case. Can you check whether removing the "~/" part from the DataImageUrlFormatString property value produces the desired result? On the online example I referenced the images reside in IMG sub-folder, see how their url format string is defined for reference.

    Best regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Steve Stilwell
    Steve Stilwell avatar
    4 posts
    Member since:
    Oct 2009

    Posted 21 Oct 2009 Link to this post

    It was my fault.  I had forgotten to copy the photos to this site.  I did and now it works great.  Thanks again.
  9. Jack
    Jack avatar
    2 posts
    Member since:
    Feb 2014

    Posted 02 Feb 2014 Link to this post

    Hello,
    I downloaded the trial and I'm trying to display image in my radgrid.
    somehow I couldn't manage to do it no matter what I did.

    my table includes a column named "picture". and in the cell of the first row of picture there is a bag.jpg value.

    the jpg file i mention above is in IMG folder.

    and here is my code:

                    <telerik:GridImageColumn DataImageUrlFields="picture"
                        DataImageUrlFormatString="IMG/{0}.jpg" HeaderText="picture" ImageHeight=""
                        ImageWidth="" SortExpression="picture" UniqueName="picture">
                    </telerik:GridImageColumn>

    I don't see any picture when I run the code. can you please help?
  10. Jack
    Jack avatar
    2 posts
    Member since:
    Feb 2014

    Posted 02 Feb 2014 in reply to Jack Link to this post

    I handled the problem. It's really weird that you can't see the image no matter what when you're in debugging. but when you go live, they appear perfectly.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017