ADD FOLDER ICON IN TREEVIEW NODE

3 posts, 0 answers
  1. beeta one
    beeta one avatar
    63 posts
    Member since:
    Aug 2012

    Posted 16 Oct 2012 Link to this post

    Hii,
    How tho add a folder icon in every node of treeview?

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

    Posted 16 Oct 2012 Link to this post

    Hi Hash,

    Try the following code snippet to achieve your scenario.

    ASPX:
    <telerik:RadTreeView ID="RadTreeView1" runat="server" Width="300px" Height="250px" OnPreRender="RadTreeView1_PreRender">
     <DataBindings>
      <telerik:RadTreeNodeBinding Expanded="True" />
     </DataBindings>
    </telerik:RadTreeView>

    C#:
    protected void RadTreeView1_PreRender(object sender, EventArgs e)
     {
      SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM tree",ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
      DataTable links = new DataTable();
      adapter.Fill(links);
      RadTreeView1.DataTextField = "name";
      RadTreeView1.DataFieldID = "id";
      RadTreeView1.DataFieldParentID = "parent";
      RadTreeView1.DataSource = links;
      RadTreeView1.DataBind();
      foreach (RadTreeNode node in RadTreeView1.GetAllNodes())
       {
        node.ImageUrl = "~/Images/folder.gif";
       }
     }

    Hope this helps.

    Regards,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 16 Oct 2012 Link to this post

    Hello Hash,

    You can set the ImageUrl property to nodes and assign the desired image.

    Kind regards,
    Kate
    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.
Back to Top