This is a migrated thread and some comments may be shown as answers.

RadBinaryImage in RadTreeList

4 Answers 72 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 19 Jun 2014, 12:43 PM
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

4 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 23 Jun 2014, 03:01 PM
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.

 
0
Jon
Top achievements
Rank 1
answered on 23 Jun 2014, 03:16 PM
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
0
Accepted
Konstantin Dikov
Telerik team
answered on 26 Jun 2014, 10:57 AM
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.

 
0
Jon
Top achievements
Rank 1
answered on 26 Jun 2014, 11:58 AM
Hi Konstantin,

Of course, obvious now!  Thanks for that.  

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

Best Regards

Jon
Tags
TreeList
Asked by
Jon
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Jon
Top achievements
Rank 1
Share this question
or