Problem in Custom Attributes

2 posts, 0 answers
  1. Eng.Bassel Samman
    Eng.Bassel Samman avatar
    25 posts
    Member since:
    Oct 2008

    Posted 17 Oct 2010 Link to this post

    I add new custom attribute to RadTreeNode using the following code:

    Nod.Attributes.Add("Key", "Value")
    Where Nod is a RadTreeNode, the attributes is added (Node attributes count is increased) but when I retrieved its value using: Nod.Attributes(Key) I always got Nothing.
    Best Regards

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Oct 2010 Link to this post


    Checkout the following example which shows how to add custom attributes in NodeDataBound event.

    <telerik:RadTreeView ID="RadTreeView2" runat="server" DataFieldID="CategoryID" DataSourceID="SqlDataSource1" 
        DataTextField="CategoryID" OnNodeDataBound="RadTreeView2_NodeDataBound" OnNodeClick="RadTreeView2_NodeClick"

    protected void RadTreeView2_NodeDataBound(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e) 
        DataRowView dataSourceRow = (DataRowView)e.Node.DataItem; 
        //set custom attributes from the datasource:   
        e.Node.Attributes["CategoryName"] = dataSourceRow["CategoryName"].ToString();   
    protected void RadTreeView2_NodeClick(object sender, RadTreeNodeEventArgs e) 
        String Name = e.Node.Text.ToString(); 
        String CategoryName = RadTreeView2.SelectedNode.Attributes["CategoryName"]; 
        Response.Write("You have selected " + Name + " with Name " + CategoryName);   

    Check with the example and see what you are missing in your code.

  3. DevCraft R3 2016 release webinar banner
Back to Top