Binding TreeView ImageURL with ObjectDataSource, it's possible?

3 posts, 0 answers
  1. Allin
    Allin avatar
    33 posts
    Member since:
    Jun 2012

    Posted 28 Mar 2013 Link to this post

    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. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 02 Apr 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Allin
    Allin avatar
    33 posts
    Member since:
    Jun 2012

    Posted 04 Apr 2013 Link to this post


    Thank you Boyan, that's work fine!



Back to Top