S
Srinivasa Raghavan
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.TreeViewClickEventArgs)
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
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.TreeViewClickEventArgs)
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