Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. Treeview SelectedNodeChanged fires for only....

Treeview SelectedNodeChanged fires for only....

Scheduled Pinned Locked Moved LINQ
graphicsdesignsysadminhelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    asifbhura
    wrote on last edited by
    #1

    hi, I have codebelow to populate treeview it works fine & binds value & text to nodes perfectly, I want to set background for selected nodes & get pathvalue of selected nodes I tried to put code inside TvFile_SelectedNodeChanged but it fires only for root node. it doenst fire for any other node.please help me to get selected node value please help me out, code Partial Class FileApplication Inherits System.Web.UI.Page Private Const VirtualImageRoot As String = "~/FileFolder/" Private ClsFileapp As New TreeFileApplication Private GetCurId As String = String.Empty Private ds As DataSet Private Sub PopulateTree() Dim rootFolder As New DirectoryInfo(Server.MapPath(VirtualImageRoot)) Dim root As TreeNode = AddNodeAndDescendent(0, Nothing) TvFile.Nodes.Add(root) End Sub Private Function AddNodeAndDescendent(ByVal val As Integer, ByVal parentNode As TreeNode) As TreeNode Dim virtualFolderPath As String ds = New DataSet() If parentNode Is Nothing Then virtualFolderPath = VirtualImageRoot ds = ClsFileapp.GetRootFolder() Else ds = ClsFileapp.GetRootFolder(val) virtualFolderPath = parentNode.Value & val & "/" End If Dim node As New TreeNode(ClsFileapp.GetfolderName(val), val) Dim reader As IDataReader = ds.CreateDataReader While reader.Read() Dim child As TreeNode = AddNodeAndDescendent(CInt(reader("id")), node) child.NavigateUrl = "FileApplication.aspx?id=" & reader("id") child.SelectAction = TreeNodeSelectAction.Expand node.ChildNodes.Add(child) End While Return node End Function Private Sub DisplayFileNFolder(ByVal folderid As String) ds = New DataSet() ds = ClsFileapp.GetFilesFolder(CInt(folderid)) If ds.Tables(0).Rows.Count > 0 Then DLDIsplayFiles.DataSource = ds DLDIsplayFiles.DataBind() End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load GetCurId = Request.QueryString.Get("id") If GetCurId IsNot Nothing Then DisplayFileNFolder(GetCurId) End If If Not IsPostBack Then PopulateTree() MPopupcreate.Hide() End If End Sub Protected Sub TvFile_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TvFile.SelectedNodeChanged TvFile.SelectedNodeStyle.BackColor = Drawing.Color.Blue End Sub End Class

    S N 2 Replies Last reply
    0
    • A asifbhura

      hi, I have codebelow to populate treeview it works fine & binds value & text to nodes perfectly, I want to set background for selected nodes & get pathvalue of selected nodes I tried to put code inside TvFile_SelectedNodeChanged but it fires only for root node. it doenst fire for any other node.please help me to get selected node value please help me out, code Partial Class FileApplication Inherits System.Web.UI.Page Private Const VirtualImageRoot As String = "~/FileFolder/" Private ClsFileapp As New TreeFileApplication Private GetCurId As String = String.Empty Private ds As DataSet Private Sub PopulateTree() Dim rootFolder As New DirectoryInfo(Server.MapPath(VirtualImageRoot)) Dim root As TreeNode = AddNodeAndDescendent(0, Nothing) TvFile.Nodes.Add(root) End Sub Private Function AddNodeAndDescendent(ByVal val As Integer, ByVal parentNode As TreeNode) As TreeNode Dim virtualFolderPath As String ds = New DataSet() If parentNode Is Nothing Then virtualFolderPath = VirtualImageRoot ds = ClsFileapp.GetRootFolder() Else ds = ClsFileapp.GetRootFolder(val) virtualFolderPath = parentNode.Value & val & "/" End If Dim node As New TreeNode(ClsFileapp.GetfolderName(val), val) Dim reader As IDataReader = ds.CreateDataReader While reader.Read() Dim child As TreeNode = AddNodeAndDescendent(CInt(reader("id")), node) child.NavigateUrl = "FileApplication.aspx?id=" & reader("id") child.SelectAction = TreeNodeSelectAction.Expand node.ChildNodes.Add(child) End While Return node End Function Private Sub DisplayFileNFolder(ByVal folderid As String) ds = New DataSet() ds = ClsFileapp.GetFilesFolder(CInt(folderid)) If ds.Tables(0).Rows.Count > 0 Then DLDIsplayFiles.DataSource = ds DLDIsplayFiles.DataBind() End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load GetCurId = Request.QueryString.Get("id") If GetCurId IsNot Nothing Then DisplayFileNFolder(GetCurId) End If If Not IsPostBack Then PopulateTree() MPopupcreate.Hide() End If End Sub Protected Sub TvFile_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TvFile.SelectedNodeChanged TvFile.SelectedNodeStyle.BackColor = Drawing.Color.Blue End Sub End Class

      S Offline
      S Offline
      SayreCC
      wrote on last edited by
      #2

      Hi, if you have code for changing the color or something of your treenode, and then it cant change, try to add property of your treenode in autopostback=true

      1 Reply Last reply
      0
      • A asifbhura

        hi, I have codebelow to populate treeview it works fine & binds value & text to nodes perfectly, I want to set background for selected nodes & get pathvalue of selected nodes I tried to put code inside TvFile_SelectedNodeChanged but it fires only for root node. it doenst fire for any other node.please help me to get selected node value please help me out, code Partial Class FileApplication Inherits System.Web.UI.Page Private Const VirtualImageRoot As String = "~/FileFolder/" Private ClsFileapp As New TreeFileApplication Private GetCurId As String = String.Empty Private ds As DataSet Private Sub PopulateTree() Dim rootFolder As New DirectoryInfo(Server.MapPath(VirtualImageRoot)) Dim root As TreeNode = AddNodeAndDescendent(0, Nothing) TvFile.Nodes.Add(root) End Sub Private Function AddNodeAndDescendent(ByVal val As Integer, ByVal parentNode As TreeNode) As TreeNode Dim virtualFolderPath As String ds = New DataSet() If parentNode Is Nothing Then virtualFolderPath = VirtualImageRoot ds = ClsFileapp.GetRootFolder() Else ds = ClsFileapp.GetRootFolder(val) virtualFolderPath = parentNode.Value & val & "/" End If Dim node As New TreeNode(ClsFileapp.GetfolderName(val), val) Dim reader As IDataReader = ds.CreateDataReader While reader.Read() Dim child As TreeNode = AddNodeAndDescendent(CInt(reader("id")), node) child.NavigateUrl = "FileApplication.aspx?id=" & reader("id") child.SelectAction = TreeNodeSelectAction.Expand node.ChildNodes.Add(child) End While Return node End Function Private Sub DisplayFileNFolder(ByVal folderid As String) ds = New DataSet() ds = ClsFileapp.GetFilesFolder(CInt(folderid)) If ds.Tables(0).Rows.Count > 0 Then DLDIsplayFiles.DataSource = ds DLDIsplayFiles.DataBind() End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load GetCurId = Request.QueryString.Get("id") If GetCurId IsNot Nothing Then DisplayFileNFolder(GetCurId) End If If Not IsPostBack Then PopulateTree() MPopupcreate.Hide() End If End Sub Protected Sub TvFile_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TvFile.SelectedNodeChanged TvFile.SelectedNodeStyle.BackColor = Drawing.Color.Blue End Sub End Class

        N Offline
        N Offline
        Niladri_Biswas
        wrote on last edited by
        #3

        Hi man, try with IValue convertor. Search google with that and also in code project itself you will find some great examples almost precisely the same as what you are looking for. Good luck. :)

        Niladri Biswas

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups