473,602 Members | 2,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
stringcollectio n 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.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
nodesChecked = New StringCollectio n()
ViewState("Sele cted") = nodesChecked
Else
nodesChecked = CType(ViewState ("Selected") ,
StringCollectio n)
End If
End Sub

Private Sub TreeView1_Check (ByVal sender As Object, ByVal
e As
Microsoft.Web.U I.WebControls.T reeViewClickEve ntArgs)
Handles TreeView1.Check
Dim treeView As TreeView
Dim node As TreeNode
Dim strNodeChecked As String

treeView = CType(sender, TreeView)
strNodeChecked = e.Node
node = treeView.GetNod eFromIndex(strN odeChecked)

' the node will have been checked or unchecked
If node.Checked = True Then
nodesChecked.Ad d(node.Text)
Else
nodesChecked.Re move(node.Text)
End If
End Sub
End Class
Thanks
Srinivasa Raghavan


Nov 17 '05 #1
2 2403
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.Ad d(node.Text)
Else
nodesChecked.Re move(node.Text)
End If

ViewState("Sele cted") = nodesChecked
Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Srinivasa Raghavan" <s_************ ******@hotmail. com> wrote in message
news:08******** *************** *****@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
stringcollectio n 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.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
nodesChecked = New StringCollectio n()
ViewState("Sele cted") = nodesChecked
Else
nodesChecked = CType(ViewState ("Selected") ,
StringCollectio n)
End If
End Sub

Private Sub TreeView1_Check (ByVal sender As Object, ByVal
e As
Microsoft.Web.U I.WebControls.T reeViewClickEve ntArgs)
Handles TreeView1.Check
Dim treeView As TreeView
Dim node As TreeNode
Dim strNodeChecked As String

treeView = CType(sender, TreeView)
strNodeChecked = e.Node
node = treeView.GetNod eFromIndex(strN odeChecked)

' the node will have been checked or unchecked
If node.Checked = True Then
nodesChecked.Ad d(node.Text)
Else
nodesChecked.Re move(node.Text)
End If
End Sub
End Class
Thanks
Srinivasa Raghavan

Nov 17 '05 #2
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.Basica lly
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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
19879
by: SoKool | last post by:
Can anyone point me to a site where I can get a free treeview control to use in ASP .NET or any tutorial that can help me build my own treeview control. I intend to use a treeview to generate a dynamic menu by collating data from a Sql Server Table. Many thanks.
8
4399
by: Hrvoje Voda | last post by:
What is wrong in this code? private void tree_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Enter ) {
3
2821
by: Peter | last post by:
Hello, We are inserting a side menu to our application using a class that is writing HTML on all our pages. This is a part of the code as an example: writer.Write(" <table WIDTH=""100%"" BORDER=""0"" CELLSPACING=""0"" CELLPADDING=""0"" ID=""Table1""> " & vbNewLine) writer.Write(" <tr>" & vbNewLine) writer.Write(" <td>" & vbNewLine)
4
14172
by: Ben Coats | last post by:
Hey, I'm trying to find code for an Explorer-style Directory ComboBox. (You know, it display "Desktop", "My Computer", all drives, etc., but it has a treeview control inside the combobox so that you can navigate through the file system as well.) I've found some on the web, but all of them just have the drives and desktop directories and are static in that you cannot expand the directories. I normally build a treeview control to do it with,...
10
2339
by: p3t3r | last post by:
I have a treeview sourced from a SiteMap. I want to use 2 different CSS styles for the root level nodes. The topmost root node should not have a top border, all the other root nodes should have a top border. Is it possible to have more than 1 style at the same level (parent node) when using a SiteMap? I want it to appear something like this and I can only find a way to either have the border on all root nodes or none at all. In...
1
2546
by: musosdev | last post by:
Hi guys I was using the Microsoft.Web.UI.WebControls extra namespace in my application to provide me with a TreeView control. I was using specifically ..GetNodeFromIndex(), SelectedNodeIndex and NodeData. All 3 of which are now giving errors is the new Asp.net TreeView. I'm found the Value property which replaces NodeData, but what about GetNodeFromIndex and SelectedNodeIndex. Are they just... gone!? :(
2
1568
by: rolf.oltmans | last post by:
Hello all, I need to place treeview control in Grid control. I need to place it in a grid because I need to show calendar against every node. Is placing a treeview in grid possible? If I need to create my own control that would include capabilities of both treeview and Grid what would I have to do? Being new to asp.net I guess I've to make a control that would inherit from treeview and grid. But would changes I've to make in my...
1
4913
by: doemon | last post by:
Hi, I'm working on a pagination control and I need to dynamically rerender a treeview to display the next set of nodes depending on which page we're on. For example, page 1 will dispaly only nodes 1 to 10, but when the user clicks , the tree will display nodes 11 to 20. Page 1 will is loaded when the page that contains the ascx (parent of the treeview) is loaded. This is all cool. The treeview displays correctly. When I click the ...
0
1983
by: noneya22 | last post by:
I want to use a TreeView control as a one-level, vertical navigation menu. I'm using this control currently with a SiteMapDataSource and .sitemap file. I've written code that associates an image with each TreeView node based upon a custom attribute I have included in the siteMapNode nodes of my .sitemap file. This all works as desired, including the security trimming which is especially desired behavior. The nodes of the TreeView...
0
12778
by: jiing | last post by:
Hi all, I want to use sting(the same as Node.Text) to judge if a node exists in TreeView. I've tried several ways, but seems all failed. could anybody help me? Thanks in advance. //My TreeView is defined to has depth =3 only.
0
7993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8404
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6730
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.