radgrid image display

8 posts, 0 answers
  1. dimis vasalos
    dimis vasalos avatar
    4 posts
    Member since:
    Nov 2009

    Posted 12 May 2011 Link to this post

    im using radgrid q3 2009.
    im loading images via code behind

    using the following code

    If

     

    TypeOf e.Item Is GridDataItem Then

     

     

    Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)

     

     

     

    If item("mattach").Text = MailHasAttach Then

     

     

    Dim img As New System.Web.UI.WebControls.Image

     

     

    img.ID =

    "attachpic"

     

    img.ImageUrl = Session(

    "virtualdir") & Session("imagepath") & "attach.gif"

     

    item(

    "mattach").Controls.Add(img)

     

     

     

    'End If

     

     

    Else

     

     

    Dim img As New System.Web.UI.WebControls.Image

     

     

    img.ID =

    "attachpic"

     

    img.ImageUrl = Session(

    "virtualdir") & Session("imagepath") & "blank.gif"

     

    item(

    "mattach").Controls.Add(img)

     

     

     

    End If

     



    when binding to datasource the images loaded in grid but when the page is refreshed without rebind it looses the images

    could you please help?

  2. Pavlina
    Admin
    Pavlina avatar
    5366 posts
    Member since:
    Sep 2012

    Posted 17 May 2011 Link to this post

    Hello Dimis,

    I suppose that you have added the images in ItemDataBound server-side event. Please note that a better approach to add a dynamically created control to GridItem is to use ItemCreated event handler.

    Also you can checkout the following documentation for more information.
    Distinguishing the major differences between ItemCreated and ItemDataBound events

    Give this suggestion a try and let me know if it helps.

    Regards,
    Pavlina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. dimis vasalos
    dimis vasalos avatar
    4 posts
    Member since:
    Nov 2009

    Posted 20 May 2011 Link to this post

    Dear Sir
    your link you have provided me Distinguishing the major differences between ItemCreated and ItemDataBound events

    does not work, and anyway i could not implement the same in itemcreated event.

    could you please give me another solution?

  4. Pavlina
    Admin
    Pavlina avatar
    5366 posts
    Member since:
    Sep 2012

    Posted 23 May 2011 Link to this post

    Hello Dimis,

    Please excuse me for the broken link. You can find the correct link here:
    http://www.telerik.com/help/aspnet-ajax/grid-distinguish-differences-between-itemcreated-itemdatabound.html

    Also, can you please specify why you can not use ItemCreted event?

    All the best,
    Pavlina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  5. dimis vasalos
    dimis vasalos avatar
    4 posts
    Member since:
    Nov 2009

    Posted 24 May 2011 Link to this post


    this is the way im doing it now but when i refresh the page im loosing the images
    is there another way i can do that without loosing the images?

    Private

     

    Sub grd_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.WebControls.GridItemEventArgs) Handles grd.ItemDataBound

     

     

     

    If TypeOf e.Item Is GridDataItem Then

     

     

    Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)

     

     

     

    If item("mattach").Text = MailHasAttach Then

     

     

    Dim img As New System.Web.UI.WebControls.Image

     

     

    img.ID =

    "attachpic"

     

    img.ImageUrl = Session(

    "virtualdir") & Session("imagepath") & "attach.gif"

     

    item(

    "mattach").Controls.Add(img)

     

     

     

    'End If

     

     

    Else

     

     

    Dim img As New System.Web.UI.WebControls.Image

     

     

    img.ID =

    "attachpic"

     

    img.ImageUrl = Session(

    "virtualdir") & Session("imagepath") & "blank.gif"

     

    item(

    "mattach").Controls.Add(img)

     

     

     

    End If

     

     

    If item("mread").Text = MailUnreaded Then

     

     

    Dim img As New System.Web.UI.WebControls.Image

     

     

    img.ID =

    "readpic"

     

    img.ImageUrl = Session(

    "virtualdir") & Session("imagepath") & "inbox.gif"

     

    item(

    "mread").Controls.Add(img)

     

     

    item.Font.Bold =

    True

     

     

    'End If

     

     

    Else

     

     

    Dim img As New System.Web.UI.WebControls.Image

     

     

    img.ID =

    "readpic"

     

    img.ImageUrl = Session(

    "virtualdir") & Session("imagepath") & "mail_readed.gif"

     

    item(

    "mread").Controls.Add(img)

     

     

    item.Font.Bold =

    False

     

     

    End If

     

     

    End If

     

     

     

     

     

     

     

     

     

     

    End Sub

     




  6. Pavlina
    Admin
    Pavlina avatar
    5366 posts
    Member since:
    Sep 2012

    Posted 24 May 2011 Link to this post

    Hello Dimis,

    I believe that this issue is caused by the fact that ItemDataBound will be called only during grid data-binding - on post back without explicit data-bind the grid will recreate child controls from ViewState and there will be no ItemDataBound. Please use ItemCreated instead to achieve this.

    Kind regards,
    Pavlina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  7. Prashant Khandalkar
    Prashant Khandalkar avatar
    3 posts
    Member since:
    Mar 2012

    Posted 21 Mar 2012 Link to this post

     I've stored path of Image in database.
    I've used telerik radgrid.
    Now I want to display image in telerik radGrid
    by the path specified in database.
    How is it Possible?
    I just did it like we do in asp:GridView but RadGrid displays path as it is instead of image.

    <telerik:GridBoundColumn DataField=Coupon_Image FilterControlAltText="Filter Image column"
                            HeaderText="Coupon_Image"
                            UniqueName="Coupon_Image">
                             
                        </telerik:GridBoundColumn>
     
    <telerik:GridBoundColumn DataField=Coupon_Image FilterControlAltText="Filter Image column"
                            HeaderText="Coupon_Image"
                            UniqueName="Coupon_Image">
                             
                        </telerik:GridBoundColumn>
    Even if I use GridBinaryImageColumn, I will have to store Image in binary format, but I want to fetch the image from database using imagepath only. Please provide me solution on how to display image on RadGrid using imagepath stored in database. I don't want to use memo type of database. I just stored imagepath in database.

  8. Pavlina
    Admin
    Pavlina avatar
    5366 posts
    Member since:
    Sep 2012

    Posted 23 Mar 2012 Link to this post

    Hello,

    Go through the forum thread below:
    http://www.telerik.com/community/forums/aspnet-ajax/grid/show-image-in-radgrid.aspx

    Greetings,
    Pavlina
    the Telerik team

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.

Back to Top