You must Sign In to post a response.
  • Category: ASP.NET

    In asp.net Treeview only folder icons in XPFileExplorer are required not file icons?

    In asp.net Treeview only folder icons in XPFileExplorer are required not file icons?
  • #761091
    Hello Bikash Panigrahi,

    Refer the below example code :

    protected void makemainNodes(TreeNodeCollection treec, System.IO.DirectoryInfo directory)
    {
    foreach (System.IO.DirectoryInfo g in directory.GetDirectories())
    {
    TreeNode child = new TreeNode(g.Name);
    System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(g.FullName);
    child.ImageUrl = "~/Images/folder.png";
    makesubNodes(child, dir);
    treec.Add(child);
    }
    }

    protected void makesubNodes(TreeNode treec, System.IO.DirectoryInfo directory)
    {
    foreach (System.IO.DirectoryInfo g in directory.GetDirectories())
    {
    TreeNode child = new TreeNode(g.Name);
    System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(g.FullName);
    child.ImageUrl = "~/Images/folder.png";
    makesubNodes(child, dir);
    treec.ChildNodes.Add(child);
    }


    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #761139
    Hai Bikash,
    You can use the code below to set the folder icon:
    1. Setting the properties of the treeview

    <asp:TreeView ID="treeView1" runat="server" ExpandDepth="1" onselectednodechanged="treeView1_SelectedNodeChanged" ontreenodeexpanded="treeView1_TreeNodeExpanded" ImageSet="XPFileExplorer" NodeIndent="15">
    </asp:TreeView>

    2. Adding the icon to the treeview:

    var treeNode = new TreeNode(name[0], file.FullName, @"~/Images/folder_Icon.gif", file.FullName, "_blank");

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


Sign In to post your comments