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

ADD FOLDER ICON IN TREEVIEW NODE

2 Answers 426 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
beeta one
Top achievements
Rank 1
beeta one asked on 16 Oct 2012, 08:33 AM
Hii,
How tho add a folder icon in every node of treeview?

thanks.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Oct 2012, 08:46 AM
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.
0
Kate
Telerik team
answered on 16 Oct 2012, 08:49 AM
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.
Tags
TreeView
Asked by
beeta one
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Kate
Telerik team
Share this question
or