ASP TreeView Control

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default ASP TreeView Control

    Hi

    I am using ASP Tree View Control to display data in
    hiearchy fashion.I am having a checkbox next to the
    TreeView Node.When user checks or unchecks the nodes and
    click a button i am putting that count in a
    stringcollection which is in viewstate.The count is wrong
    after certain checks and click of the button.can any one
    explain what could be wrong.

    Here is the code below.
    nodeschecked count is going wrong what could be reason.

    Private Sub Page_Load(ByVal sender As System.Object, ByVal
    e As
    System.EventArgs) Handles MyBase.Load
    If Not IsPostBack Then
    nodesChecked = New StringCollection()
    ViewState("Selected") = nodesChecked
    Else
    nodesChecked = CType(ViewState("Selected"),
    StringCollection)
    End If
    End Sub

    Private Sub TreeView1_Check(ByVal sender As Object, ByVal
    e As
    Microsoft.Web.UI.WebControls.TreeViewClickEventArg s)
    Handles TreeView1.Check
    Dim treeView As TreeView
    Dim node As TreeNode
    Dim strNodeChecked As String

    treeView = CType(sender, TreeView)
    strNodeChecked = e.Node
    node = treeView.GetNodeFromIndex(strNodeChecked)

    ' the node will have been checked or unchecked
    If node.Checked = True Then
    nodesChecked.Add(node.Text)
    Else
    nodesChecked.Remove(node.Text)
    End If


    End Sub
    End Class


    Thanks
    Srinivasa Raghavan




    Srinivasa Raghavan Guest

  2. Similar Questions and Discussions

    1. TreeView in Web Custom Control
      Hi. I'm trying to develop a web custom control that uses a programmatically created treeview. My problem is that I get an exception when I try to...
    2. Adding contextmenu to IE Treeview Control
      Does anybody have a clue as to how to do this? I would like to display my own custom context menu when rightclicking a node in my treeview, but...
    3. TreeView Control
      Vijay, You can use the TreeView webcontrol that comes with the iewebcontrols which are downloadable from MS site. They are 'unsupported',...
    4. Problem with Treeview Control & Toolbar
      Hi all I have a few problems with my Access 2000 application that I wrote. 1.I have added a Microsoft Treview control version 6.0 control to...
    5. Having a difficulty working with the Treeview Web Control
      Hi, I have answered your question in: microsoft.public.dotnet.framework.aspnet.webcontrols Pls don't do crossposting. Some won't answer your...
  3. #2

    Default Re: ASP TreeView Control

    Srinivasa,

    Your code looks fine except for one small thing: In your Sub
    TreeView1_Check I don't see where you are saving the new nodesChecked object
    to view state. If you don't re-save it to the view state variable every page
    load the view state is re-setting it to the empty value.

    Change your code to look like this and it will work I think:

    ' the node will have been checked or unchecked
    If node.Checked = True Then
    nodesChecked.Add(node.Text)
    Else
    nodesChecked.Remove(node.Text)
    End If

    ViewState("Selected") = nodesChecked


    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche


    "Srinivasa Raghavan" <s_srinivasa_raghavan@hotmail.com> wrote in message
    news:081701c35dab$b9264670$a501280a@phx.gbl...
    > Hi
    >
    > I am using ASP Tree View Control to display data in
    > hiearchy fashion.I am having a checkbox next to the
    > TreeView Node.When user checks or unchecks the nodes and
    > click a button i am putting that count in a
    > stringcollection which is in viewstate.The count is wrong
    > after certain checks and click of the button.can any one
    > explain what could be wrong.
    >
    > Here is the code below.
    > nodeschecked count is going wrong what could be reason.
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal
    > e As
    > System.EventArgs) Handles MyBase.Load
    > If Not IsPostBack Then
    > nodesChecked = New StringCollection()
    > ViewState("Selected") = nodesChecked
    > Else
    > nodesChecked = CType(ViewState("Selected"),
    > StringCollection)
    > End If
    > End Sub
    >
    > Private Sub TreeView1_Check(ByVal sender As Object, ByVal
    > e As
    > Microsoft.Web.UI.WebControls.TreeViewClickEventArg s)
    > Handles TreeView1.Check
    > Dim treeView As TreeView
    > Dim node As TreeNode
    > Dim strNodeChecked As String
    >
    > treeView = CType(sender, TreeView)
    > strNodeChecked = e.Node
    > node = treeView.GetNodeFromIndex(strNodeChecked)
    >
    > ' the node will have been checked or unchecked
    > If node.Checked = True Then
    > nodesChecked.Add(node.Text)
    > Else
    > nodesChecked.Remove(node.Text)
    > End If
    >
    >
    > End Sub
    > End Class
    >
    >
    > Thanks
    > Srinivasa Raghavan
    >
    >
    >
    >

    S. Justin Gengo Guest

  4. #3

    Default Re: ASP TreeView Control

    Hi


    I am storing cookies in the client side using httpcookie object.It is
    working in IE and not in netscape.please suggest a solution.


    I am having javascript which works in IE and not in Netscape.Basically
    when clicking checkbox in grid i call the javascript.In Netscape the i
    am unable to deselected the checkbox once selected.



    Thanks
    Srinivasa Raghavan




    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Srinivasa Raghavan Sethuraman Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139