RadBinaryImage in RadTreeList

5 posts, 1 answers
  1. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 19 Jun 2014 Link to this post

    I normally use a grid along with a gridbinaryimagecolumn to display images from the database in my grid.

    How do I go about doing the same thing in a RadTreeList?  I've tried with a template column and a radbinaryimage but can't get a way of storing the database driven image into a hidden column.

    Any suggestions?

    Regards

    Jon
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 23 Jun 2014 Link to this post

    Hello Jon,

    Since RadTreeList does not have BinaryImageColumn, what you could do is to use TreeListTemplateColumn and place RadBinaryImage control in the ItemTemplate. Following is a simple example demonstrating such approach, where the BinaryImage field is of byte[] type:
    <telerik:RadTreeList runat="server" ID="RadTreeList1" DataKeyNames="ID" ParentDataKeyNames="ParentID"
         OnNeedDataSource="RadTreeList1_NeedDataSource" AutoGenerateColumns="false">
        <Columns>
            <telerik:TreeListBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID">
            </telerik:TreeListBoundColumn>
            <telerik:TreeListTemplateColumn>
                <ItemTemplate>
                    <telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" DataValue='<%#Eval("BinaryImage") %>' />
                </ItemTemplate>
            </telerik:TreeListTemplateColumn>
        </Columns>
    </telerik:RadTreeList>

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 23 Jun 2014 in reply to Konstantin Dikov Link to this post

    Hi Konstantin,

    Ah yes - I missed that one - I'll put it down to the bad cold that I had last week!

    What is the best approach for handling a Null field value in this instance?  

    Regards

    Jon
  5. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 26 Jun 2014 Link to this post

    Hello Jon,

    For handling null values you could use the following approach:
    <telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" DataValue='<%#  Eval("BinaryImage") is DBNull ? new byte[0] : Eval("BinaryImage")   %>' />

    However, since the above will still try to display an image, I could suggest an approach where you add a default image (like NoImage template) or set the control visibility to false if the value is null:
    <telerik:RadBinaryImage runat="server" Visible='<%# !(Eval("BinaryImage") is DBNull)  %>' ID="RadBinaryImage1" DataValue='<%#  Eval("BinaryImage") is DBNull ? new byte[0] : Eval("BinaryImage")   %>' />

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 26 Jun 2014 in reply to Konstantin Dikov Link to this post

    Hi Konstantin,

    Of course, obvious now!  Thanks for that.  

    The page looks superb now - a very useful addition :)

    Best Regards

    Jon
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017