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

Binding TreeView ImageURL with ObjectDataSource, it's possible?

2 Answers 85 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Allin
Top achievements
Rank 1
Allin asked on 28 Mar 2013, 06:04 PM
Hi,

I tried to bind ImageUrl property with ObjectDataSource without success. I look all demo and exemple for this work and i can't find how to bind this property.

My treeView display the text and build good structure, mais i can't set ImageUrl from my object.

I tried this in the markup 
ImageUrl="Image"
<telerik:RadTreeView ID="rtvNavigation" runat="server"
    MultipleSelect="false"
    Font-Size="9pt"
    Height="94%"
    Width="100%"
    DataSourceID="ObjectDataSource1"
    DataTextField="Description"
    DataFieldID="ID"
    DataFieldParentID="ParentID"
    AllowNodeEditing="false"         
    ImageUrl="Image"       
    OnNodeClick="rtvNavigation_NodeClick">
</telerik:RadTreeView>
and onNodeDataBound event, i can't set this imageURL because the ID is always empty.

Thank you for help!




2 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 02 Apr 2013, 10:10 AM
Hello,

I would recommend to use the RadTreeView NodeDataBound server-side event in order to achieve such scenario.
//code behind

protected void RadTreeView1_NodeDataBound(object sender, RadTreeNodeEventArgs e)
   {
       //in this specific case the TypeName="SiteDataItem" and the property that holds ImageUrl value is ImageUrl
       SiteDataItem dataItem = (SiteDataItem)e.Node.DataItem;
       e.Node.ImageUrl = dataItem.ImageUrl;
   }

Please find attached a sample project that implements the described scenario. Please keep in mind that the custom class SiteDataItem implementation is located in the App_Code folder.

Regards,
Boyan Dimitrov
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.
0
Allin
Top achievements
Rank 1
answered on 04 Apr 2013, 12:46 PM

Thank you Boyan, that's work fine!



Tags
TreeView
Asked by
Allin
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Allin
Top achievements
Rank 1
Share this question
or